Skip to content

fix: support gno crossing entry points and build.env driver - #58

Draft
davd-gzl wants to merge 2 commits into
gnoverse:mainfrom
davd-gzl:fix/gno-builtin-shim-drift
Draft

fix: support gno crossing entry points and build.env driver#58
davd-gzl wants to merge 2 commits into
gnoverse:mainfrom
davd-gzl:fix/gno-builtin-shim-drift

Conversation

@davd-gzl

@davd-gzl davd-gzl commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

A folder that configures its go/packages driver through gnopls' build.env setting never reached the in-process resolver, because the selection read GOPACKAGESDRIVER from the process environment instead. Such a folder was left with a driver that is never installed, and go/packages would then try to exec ":memory:" as a binary. This selects the resolver from the folder's effective driver.

Separately, go/types rejects func init(cur realm) and func main(cur realm), the crossing forms that gno accepts and binds cur to the current realm. This drops the signature error for those two forms. go/types reports init under InvalidInitDecl and main under InvalidMainDecl, so both codes are matched, and declarations carrying type parameters are left alone because their complaint shares the same code. Entry points that are wrong in gno as well as in Go keep reporting.

Adds end-to-end tests that a realm package using the gno universe scope produces no diagnostics, that the crossing form of main is accepted in package main, and that non-crossing init forms still report, plus a regression test that the standard libraries living only under gnovm/tests/stdlibs stay resolvable.

Verified with go test -count=1 ./pkg/..., which is what CI runs. In the integration diagnostics package the failure count is unchanged against main at 47, with the three new tests passing on top. Note that package is slow by default: each test's deadline is derived from go test -timeout, so GOPLS_INTEGRATION_TEST_TIMEOUT=60s keeps a run to a couple of minutes.

Two things kept a gno realm package from type-checking cleanly.

The in-process resolver was selected by reading GOPACKAGESDRIVER from the
process environment. A folder that configures the driver through gnopls'
build.env setting was left with a GoPackagesDriverView whose driver is never
installed, and go/packages then tried to exec ":memory:" as a binary. Select it
from the folder's effective driver instead.

go/types rejects func init(cur realm) and func main(cur realm), which gno
accepts and binds cur to the current realm. Drop the InvalidInitDecl error for
those two signatures only. The parameter still resolves inside the body, so
only the signature complaint has to go, and init declarations that are wrong in
gno as well as in Go keep reporting.

Add an end-to-end test that a realm package using the gno universe scope
produces no diagnostics, and a regression test that the standard libraries
living only under gnovm/tests/stdlibs stay resolvable.
@davd-gzl
davd-gzl force-pushed the fix/gno-builtin-shim-drift branch from 1f5bc1c to 9106879 Compare August 3, 2026 21:14
@davd-gzl davd-gzl changed the title fix: resolve gno builtins through the universe scope fix: support gno crossing entry points and build.env driver Aug 3, 2026
go/types reports the entry point signature complaint under two codes: init
under InvalidInitDecl and main under InvalidMainDecl. Only the former was
matched, so `func main(cur realm)` in package main still reported a spurious
error even though the crossing form is what gno expects.

Match both codes, and leave declarations carrying type parameters alone,
because go/types reuses the same code for the "must have no type parameters"
complaint, which gno rejects as well.

Cover main in the integration tests, which had no package main case at all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant