From 0c683948792b0b0e07be236da8ff8aaaa5b2efc7 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Thu, 16 Nov 2023 18:48:44 +0100 Subject: [PATCH] refactor!: remove `gno build` command (#1297) Closes: #1242 In favor of `gno precompile -gobuild`. As seen in the tests written for `gno build` in this PR #1103, the command's behavior is kinda unexpected. It actually doesn't care about the syntax of gno files and only relies on go files found in the path passed as an argument. Because of that, I chose to name the flag `-gobuild` instead of `-build` because I found that represents better what's really happening when this flag is provided. As mentioned in the linked issue, `gno build` will be re-implemented in the future with an other behavior.
Contributors' checklist... - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
--- .github/workflows/examples.yml | 3 +- gnovm/cmd/gno/build.go | 92 ------------------- gnovm/cmd/gno/build_test.go | 25 ----- gnovm/cmd/gno/main.go | 1 - gnovm/cmd/gno/precompile.go | 46 +++++++++- gnovm/cmd/gno/precompile_test.go | 32 ++++--- gnovm/cmd/gno/test.go | 2 +- .../gno/testdata/gno_build/empty_dir.txtar | 6 -- .../gno_build/invalid_gno_files.txtar | 27 ------ .../testdata/gno_build/invalid_go_files.txtar | 30 ------ .../cmd/gno/testdata/gno_build/no_args.txtar | 6 -- .../gno/testdata/gno_build/no_gno_files.txtar | 12 --- .../gno/testdata/gno_build/no_go_files.txtar | 19 ---- .../cmd/gno/testdata/gno_build/no_gomod.txtar | 16 ---- gnovm/cmd/gno/testdata/gno_build/ok.txtar | 23 ----- .../testdata/gno_precompile/01_no_args.txtar | 6 ++ .../gno_precompile/02_empty_dir.txtar | 6 ++ .../gno_precompile/03_invalid_gno_files.txtar | 19 ++++ .../gno_precompile/04_valid_gno_files.txtar | 32 +++++++ .../gno_precompile/05_skip_fmt_flag.txtar | 34 +++++++ .../gno_precompile/06_build_flag.txtar | 36 ++++++++ .../07_build_flag_with_build_error.txtar | 34 +++++++ gnovm/pkg/gnolang/precompile.go | 5 +- 23 files changed, 237 insertions(+), 275 deletions(-) delete mode 100644 gnovm/cmd/gno/build.go delete mode 100644 gnovm/cmd/gno/build_test.go delete mode 100644 gnovm/cmd/gno/testdata/gno_build/empty_dir.txtar delete mode 100644 gnovm/cmd/gno/testdata/gno_build/invalid_gno_files.txtar delete mode 100644 gnovm/cmd/gno/testdata/gno_build/invalid_go_files.txtar delete mode 100644 gnovm/cmd/gno/testdata/gno_build/no_args.txtar delete mode 100644 gnovm/cmd/gno/testdata/gno_build/no_gno_files.txtar delete mode 100644 gnovm/cmd/gno/testdata/gno_build/no_go_files.txtar delete mode 100644 gnovm/cmd/gno/testdata/gno_build/no_gomod.txtar delete mode 100644 gnovm/cmd/gno/testdata/gno_build/ok.txtar create mode 100644 gnovm/cmd/gno/testdata/gno_precompile/01_no_args.txtar create mode 100644 gnovm/cmd/gno/testdata/gno_precompile/02_empty_dir.txtar create mode 100644 gnovm/cmd/gno/testdata/gno_precompile/03_invalid_gno_files.txtar create mode 100644 gnovm/cmd/gno/testdata/gno_precompile/04_valid_gno_files.txtar create mode 100644 gnovm/cmd/gno/testdata/gno_precompile/05_skip_fmt_flag.txtar create mode 100644 gnovm/cmd/gno/testdata/gno_precompile/06_build_flag.txtar create mode 100644 gnovm/cmd/gno/testdata/gno_precompile/07_build_flag_with_build_error.txtar diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index f69a27d15b6..b72b9b24dc1 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -32,8 +32,7 @@ jobs: with: go-version: ${{ matrix.goversion }} - run: go install -v ./gnovm/cmd/gno - - run: go run ./gnovm/cmd/gno precompile --verbose ./examples - - run: go run ./gnovm/cmd/gno build --verbose ./examples + - run: go run ./gnovm/cmd/gno precompile --verbose --gobuild ./examples test: strategy: fail-fast: false diff --git a/gnovm/cmd/gno/build.go b/gnovm/cmd/gno/build.go deleted file mode 100644 index 7396d17fd8f..00000000000 --- a/gnovm/cmd/gno/build.go +++ /dev/null @@ -1,92 +0,0 @@ -package main - -import ( - "context" - "flag" - "fmt" - "os" - - gno "github.com/gnolang/gno/gnovm/pkg/gnolang" - "github.com/gnolang/gno/tm2/pkg/commands" -) - -type buildCfg struct { - verbose bool - goBinary string -} - -var defaultBuildOptions = &buildCfg{ - verbose: false, - goBinary: "go", -} - -func newBuildCmd(io commands.IO) *commands.Command { - cfg := &buildCfg{} - - return commands.NewCommand( - commands.Metadata{ - Name: "build", - ShortUsage: "build [flags] ", - ShortHelp: "Builds the specified gno package", - }, - cfg, - func(_ context.Context, args []string) error { - return execBuild(cfg, args, io) - }, - ) -} - -func (c *buildCfg) RegisterFlags(fs *flag.FlagSet) { - fs.BoolVar( - &c.verbose, - "verbose", - defaultBuildOptions.verbose, - "verbose output when building", - ) - - fs.StringVar( - &c.goBinary, - "go-binary", - defaultBuildOptions.goBinary, - "go binary to use for building", - ) -} - -func execBuild(cfg *buildCfg, args []string, io commands.IO) error { - if len(args) < 1 { - return flag.ErrHelp - } - - paths, err := gnoPackagesFromArgs(args) - if err != nil { - return fmt.Errorf("list packages: %w", err) - } - - errCount := 0 - for _, pkgPath := range paths { - err = goBuildFileOrPkg(pkgPath, cfg) - if err != nil { - err = fmt.Errorf("%s: build pkg: %w", pkgPath, err) - io.ErrPrintfln("%s\n", err.Error()) - - errCount++ - } - } - - if errCount > 0 { - return fmt.Errorf("%d go build errors", errCount) - } - - return nil -} - -func goBuildFileOrPkg(fileOrPkg string, cfg *buildCfg) error { - verbose := cfg.verbose - goBinary := cfg.goBinary - - if verbose { - fmt.Fprintf(os.Stderr, "%s\n", fileOrPkg) - } - - return gno.PrecompileBuildPackage(fileOrPkg, goBinary) -} diff --git a/gnovm/cmd/gno/build_test.go b/gnovm/cmd/gno/build_test.go deleted file mode 100644 index 81aed7d1c79..00000000000 --- a/gnovm/cmd/gno/build_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "testing" - - "github.com/gnolang/gno/gnovm/pkg/integration" - "github.com/rogpeppe/go-internal/testscript" - "github.com/stretchr/testify/require" -) - -func Test_ScriptsBuild(t *testing.T) { - p := testscript.Params{ - Dir: "testdata/gno_build", - } - - if coverdir, ok := integration.ResolveCoverageDir(); ok { - err := integration.SetupTestscriptsCoverage(&p, coverdir) - require.NoError(t, err) - } - - err := integration.SetupGno(&p, t.TempDir()) - require.NoError(t, err) - - testscript.Run(t, p) -} diff --git a/gnovm/cmd/gno/main.go b/gnovm/cmd/gno/main.go index c84aa52fc86..751a78748f4 100644 --- a/gnovm/cmd/gno/main.go +++ b/gnovm/cmd/gno/main.go @@ -33,7 +33,6 @@ func newGnocliCmd(io commands.IO) *commands.Command { newTestCmd(io), newLintCmd(io), newRunCmd(io), - newBuildCmd(io), newPrecompileCmd(io), newCleanCmd(io), newReplCmd(), diff --git a/gnovm/cmd/gno/precompile.go b/gnovm/cmd/gno/precompile.go index 4a4528001a2..5583e3d8429 100644 --- a/gnovm/cmd/gno/precompile.go +++ b/gnovm/cmd/gno/precompile.go @@ -18,6 +18,7 @@ type precompileCfg struct { verbose bool skipFmt bool skipImports bool + gobuild bool goBinary string gofmtBinary string output string @@ -30,6 +31,11 @@ type precompileOptions struct { precompiled map[importPath]struct{} } +var defaultPrecompileCfg = &precompileCfg{ + verbose: false, + goBinary: "go", +} + func newPrecompileOptions(cfg *precompileCfg) *precompileOptions { return &precompileOptions{cfg, map[importPath]struct{}{}} } @@ -85,6 +91,13 @@ func (c *precompileCfg) RegisterFlags(fs *flag.FlagSet) { "do not precompile imports recursively", ) + fs.BoolVar( + &c.gobuild, + "gobuild", + false, + "run go build on generated go files, ignoring test files", + ) + fs.StringVar( &c.goBinary, "go-binary", @@ -125,7 +138,6 @@ func execPrecompile(cfg *precompileCfg, args []string, io commands.IO) error { if err != nil { err = fmt.Errorf("%s: precompile: %w", filepath, err) io.ErrPrintfln("%s", err.Error()) - errCount++ } } @@ -134,6 +146,27 @@ func execPrecompile(cfg *precompileCfg, args []string, io commands.IO) error { return fmt.Errorf("%d precompile errors", errCount) } + if cfg.gobuild { + paths, err := gnoPackagesFromArgs(args) + if err != nil { + return fmt.Errorf("list packages: %w", err) + } + + errCount = 0 + for _, pkgPath := range paths { + _ = pkgPath + err = goBuildFileOrPkg(pkgPath, cfg) + if err != nil { + err = fmt.Errorf("%s: build pkg: %w", pkgPath, err) + io.ErrPrintfln("%s\n", err.Error()) + errCount++ + } + } + if errCount > 0 { + return fmt.Errorf("%d build errors", errCount) + } + } + return nil } @@ -219,3 +252,14 @@ func precompileFile(srcPath string, opts *precompileOptions) error { return nil } + +func goBuildFileOrPkg(fileOrPkg string, cfg *precompileCfg) error { + verbose := cfg.verbose + goBinary := cfg.goBinary + + if verbose { + fmt.Fprintf(os.Stderr, "%s\n", fileOrPkg) + } + + return gno.PrecompileBuildPackage(fileOrPkg, goBinary) +} diff --git a/gnovm/cmd/gno/precompile_test.go b/gnovm/cmd/gno/precompile_test.go index 56f63b0de35..f8436fad768 100644 --- a/gnovm/cmd/gno/precompile_test.go +++ b/gnovm/cmd/gno/precompile_test.go @@ -1,18 +1,26 @@ package main -import "testing" +import ( + "testing" -func TestPrecompileApp(t *testing.T) { - tc := []testMainCase{ - { - args: []string{"precompile"}, - errShouldBe: "flag: help requested", - }, + "github.com/rogpeppe/go-internal/testscript" + "github.com/stretchr/testify/require" - // {args: []string{"precompile", "..."}, stdoutShouldContain: "..."}, - // TODO: recursive - // TODO: valid files - // TODO: invalid files + "github.com/gnolang/gno/gnovm/pkg/integration" +) + +func Test_ScriptsPrecompile(t *testing.T) { + p := testscript.Params{ + Dir: "testdata/gno_precompile", + } + + if coverdir, ok := integration.ResolveCoverageDir(); ok { + err := integration.SetupTestscriptsCoverage(&p, coverdir) + require.NoError(t, err) } - testMainCaseRun(t, tc) + + err := integration.SetupGno(&p, t.TempDir()) + require.NoError(t, err) + + testscript.Run(t, p) } diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index 718235c1390..edfd36efed3 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -231,7 +231,7 @@ func execTest(cfg *testCfg, args []string, io commands.IO) error { if err != nil { return errors.New("cannot resolve build dir") } - err = goBuildFileOrPkg(tempDir, defaultBuildOptions) + err = goBuildFileOrPkg(tempDir, defaultPrecompileCfg) if err != nil { io.ErrPrintln(err) io.ErrPrintln("FAIL") diff --git a/gnovm/cmd/gno/testdata/gno_build/empty_dir.txtar b/gnovm/cmd/gno/testdata/gno_build/empty_dir.txtar deleted file mode 100644 index d346b6ad46f..00000000000 --- a/gnovm/cmd/gno/testdata/gno_build/empty_dir.txtar +++ /dev/null @@ -1,6 +0,0 @@ -# Run gno build on an empty dir - -gno build . - -! stdout .+ -! stderr .+ diff --git a/gnovm/cmd/gno/testdata/gno_build/invalid_gno_files.txtar b/gnovm/cmd/gno/testdata/gno_build/invalid_gno_files.txtar deleted file mode 100644 index 617e12291be..00000000000 --- a/gnovm/cmd/gno/testdata/gno_build/invalid_gno_files.txtar +++ /dev/null @@ -1,27 +0,0 @@ -# Run gno build with invalid gno files (still success) - -gno build . - -! stdout .+ -! stderr .+ - --- go.mod -- -module gnobuild - --- file1.go -- -package file1 - --- main.gno -- -package main - -invalid - -func main() {} - --- sub/sub.gno -- -package sub - -invalid - --- sub/file2.go -- -package file2 diff --git a/gnovm/cmd/gno/testdata/gno_build/invalid_go_files.txtar b/gnovm/cmd/gno/testdata/gno_build/invalid_go_files.txtar deleted file mode 100644 index a7c8b51af49..00000000000 --- a/gnovm/cmd/gno/testdata/gno_build/invalid_go_files.txtar +++ /dev/null @@ -1,30 +0,0 @@ -# Run gno build with invalid go files - -! gno build . - -! stdout .+ -stderr '\./file1\.go:3:1: syntax error: non-declaration statement outside function body' -stderr '\./\.: build pkg: std go compiler' -stderr 'sub/file2\.go:3:1: syntax error: non-declaration statement outside function body' -stderr '\./sub: build pkg: std go compiler' - --- go.mod -- -module gnobuild - --- file1.go -- -package file1 - -invalid1 - --- main.gno -- -package main - -func main() {} - --- sub/sub.gno -- -package sub - --- sub/file2.go -- -package file2 - -invalid2 diff --git a/gnovm/cmd/gno/testdata/gno_build/no_args.txtar b/gnovm/cmd/gno/testdata/gno_build/no_args.txtar deleted file mode 100644 index b3f68676588..00000000000 --- a/gnovm/cmd/gno/testdata/gno_build/no_args.txtar +++ /dev/null @@ -1,6 +0,0 @@ -# Run gno build without args - -! gno build - -! stdout .+ -stderr 'flag: help requested' diff --git a/gnovm/cmd/gno/testdata/gno_build/no_gno_files.txtar b/gnovm/cmd/gno/testdata/gno_build/no_gno_files.txtar deleted file mode 100644 index 58261e77cda..00000000000 --- a/gnovm/cmd/gno/testdata/gno_build/no_gno_files.txtar +++ /dev/null @@ -1,12 +0,0 @@ -# Run gno build on a dir w/o gno files - -gno build . - -! stdout .+ -! stderr .+ - --- README -- -Hello world - --- sub/README -- -Hello world diff --git a/gnovm/cmd/gno/testdata/gno_build/no_go_files.txtar b/gnovm/cmd/gno/testdata/gno_build/no_go_files.txtar deleted file mode 100644 index 46559610ccf..00000000000 --- a/gnovm/cmd/gno/testdata/gno_build/no_go_files.txtar +++ /dev/null @@ -1,19 +0,0 @@ -# Run gno build in a dir without go files - -! gno build . - -! stdout .+ -stderr -count=2 'no Go files in '$WORK -stderr '\./\.: build pkg: std go compiler' -stderr '\./sub: build pkg: std go compiler' - --- go.mod -- -module gnobuild - --- main.gno -- -package main - -func main() {} - --- sub/sub.gno -- -package sub diff --git a/gnovm/cmd/gno/testdata/gno_build/no_gomod.txtar b/gnovm/cmd/gno/testdata/gno_build/no_gomod.txtar deleted file mode 100644 index 9e6cad05664..00000000000 --- a/gnovm/cmd/gno/testdata/gno_build/no_gomod.txtar +++ /dev/null @@ -1,16 +0,0 @@ -# Run gno build on a dir without go.mod - -! gno build . - -! stdout .+ -stderr -count=2 'go: go.mod file not found in current directory or any parent directory' -stderr './.: build pkg: std go compiler' -stderr './sub: build pkg: std go compiler' - --- main.gno -- -package main - -func main() {} - --- sub/sub.gno -- -package sub diff --git a/gnovm/cmd/gno/testdata/gno_build/ok.txtar b/gnovm/cmd/gno/testdata/gno_build/ok.txtar deleted file mode 100644 index 9d70fd97904..00000000000 --- a/gnovm/cmd/gno/testdata/gno_build/ok.txtar +++ /dev/null @@ -1,23 +0,0 @@ -# Run gno build successfully - -gno build . - -! stdout .+ -! stderr .+ - --- go.mod -- -module gnobuild - --- file1.go -- -package file1 - --- main.gno -- -package main - -func main() {} - --- sub/sub.gno -- -package sub - --- sub/file2.go -- -package file2 diff --git a/gnovm/cmd/gno/testdata/gno_precompile/01_no_args.txtar b/gnovm/cmd/gno/testdata/gno_precompile/01_no_args.txtar new file mode 100644 index 00000000000..944c74ee615 --- /dev/null +++ b/gnovm/cmd/gno/testdata/gno_precompile/01_no_args.txtar @@ -0,0 +1,6 @@ +# Run gno precompile without args + +! gno precompile + +! stdout .+ +stderr 'flag: help requested' diff --git a/gnovm/cmd/gno/testdata/gno_precompile/02_empty_dir.txtar b/gnovm/cmd/gno/testdata/gno_precompile/02_empty_dir.txtar new file mode 100644 index 00000000000..7afc7ed0683 --- /dev/null +++ b/gnovm/cmd/gno/testdata/gno_precompile/02_empty_dir.txtar @@ -0,0 +1,6 @@ +# Run gno precompile on an empty dir + +gno precompile . + +! stdout .+ +! stderr .+ diff --git a/gnovm/cmd/gno/testdata/gno_precompile/03_invalid_gno_files.txtar b/gnovm/cmd/gno/testdata/gno_precompile/03_invalid_gno_files.txtar new file mode 100644 index 00000000000..26e12a9c750 --- /dev/null +++ b/gnovm/cmd/gno/testdata/gno_precompile/03_invalid_gno_files.txtar @@ -0,0 +1,19 @@ +# Run gno precompile with invalid gno files + +! gno precompile . + +! stdout .+ +stderr 'precompile: parse: main.gno:3:1: expected declaration, found invalid' +stderr 'precompile: parse: sub/sub.gno:3:1: expected declaration, found invalid' + +-- main.gno -- +package main + +invalid + +func main() {} + +-- sub/sub.gno -- +package sub + +invalid diff --git a/gnovm/cmd/gno/testdata/gno_precompile/04_valid_gno_files.txtar b/gnovm/cmd/gno/testdata/gno_precompile/04_valid_gno_files.txtar new file mode 100644 index 00000000000..0f9d909f627 --- /dev/null +++ b/gnovm/cmd/gno/testdata/gno_precompile/04_valid_gno_files.txtar @@ -0,0 +1,32 @@ +# Run gno precompile with valid gno files + +gno precompile . + +! stdout .+ +! stderr .+ + +cmp main.gno.gen.go main.gno.gen.go.golden +cmp sub/sub.gno.gen.go sub/sub.gno.gen.go.golden + +-- main.gno -- +package main + +func main(){} + +-- sub/sub.gno -- +package sub + +-- main.gno.gen.go.golden -- +// Code generated by github.com/gnolang/gno. DO NOT EDIT. + +//go:build gno + +package main + +func main() {} +-- sub/sub.gno.gen.go.golden -- +// Code generated by github.com/gnolang/gno. DO NOT EDIT. + +//go:build gno + +package sub diff --git a/gnovm/cmd/gno/testdata/gno_precompile/05_skip_fmt_flag.txtar b/gnovm/cmd/gno/testdata/gno_precompile/05_skip_fmt_flag.txtar new file mode 100644 index 00000000000..0f7780efdad --- /dev/null +++ b/gnovm/cmd/gno/testdata/gno_precompile/05_skip_fmt_flag.txtar @@ -0,0 +1,34 @@ +# Run gno precompile with -skip-fmt flag +# NOTE(tb): this flag doesn't actually prevent the code format, because +# `gnolang.Precompile()` calls `format.Node()`. + +gno precompile -skip-fmt . + +! stdout .+ +! stderr .+ + +cmp main.gno.gen.go main.gno.gen.go.golden +cmp sub/sub.gno.gen.go sub/sub.gno.gen.go.golden + +-- main.gno -- +package main + +func main(){} + +-- sub/sub.gno -- +package sub + +-- main.gno.gen.go.golden -- +// Code generated by github.com/gnolang/gno. DO NOT EDIT. + +//go:build gno + +package main + +func main() {} +-- sub/sub.gno.gen.go.golden -- +// Code generated by github.com/gnolang/gno. DO NOT EDIT. + +//go:build gno + +package sub diff --git a/gnovm/cmd/gno/testdata/gno_precompile/06_build_flag.txtar b/gnovm/cmd/gno/testdata/gno_precompile/06_build_flag.txtar new file mode 100644 index 00000000000..b93fae95fcf --- /dev/null +++ b/gnovm/cmd/gno/testdata/gno_precompile/06_build_flag.txtar @@ -0,0 +1,36 @@ +# Run gno precompile with -gobuild flag + +gno precompile -gobuild . + +! stdout .+ +! stderr .+ + +cmp main.gno.gen.go main.gno.gen.go.golden +cmp sub/sub.gno.gen.go sub/sub.gno.gen.go.golden + +-- main.gno -- +package main + +func main() { + var x = 1 + _=x +} +-- sub/sub.gno -- +package sub +-- main.gno.gen.go.golden -- +// Code generated by github.com/gnolang/gno. DO NOT EDIT. + +//go:build gno + +package main + +func main() { + var x = 1 + _ = x +} +-- sub/sub.gno.gen.go.golden -- +// Code generated by github.com/gnolang/gno. DO NOT EDIT. + +//go:build gno + +package sub diff --git a/gnovm/cmd/gno/testdata/gno_precompile/07_build_flag_with_build_error.txtar b/gnovm/cmd/gno/testdata/gno_precompile/07_build_flag_with_build_error.txtar new file mode 100644 index 00000000000..6543623b266 --- /dev/null +++ b/gnovm/cmd/gno/testdata/gno_precompile/07_build_flag_with_build_error.txtar @@ -0,0 +1,34 @@ +# Run gno precompile with -gobuild flag + +! gno precompile -gobuild . + +! stdout .+ +stderr './main.gno.gen.go:8:6: x declared and not used' + +cmp main.gno.gen.go main.gno.gen.go.golden +cmp sub/sub.gno.gen.go sub/sub.gno.gen.go.golden + +-- main.gno -- +package main + +func main() { + var x = 1 +} +-- sub/sub.gno -- +package sub +-- main.gno.gen.go.golden -- +// Code generated by github.com/gnolang/gno. DO NOT EDIT. + +//go:build gno + +package main + +func main() { + var x = 1 +} +-- sub/sub.gno.gen.go.golden -- +// Code generated by github.com/gnolang/gno. DO NOT EDIT. + +//go:build gno + +package sub diff --git a/gnovm/pkg/gnolang/precompile.go b/gnovm/pkg/gnolang/precompile.go index c3116f25800..db0257fb63d 100644 --- a/gnovm/pkg/gnolang/precompile.go +++ b/gnovm/pkg/gnolang/precompile.go @@ -13,9 +13,10 @@ import ( "sort" "strings" - "github.com/gnolang/gno/tm2/pkg/std" "go.uber.org/multierr" "golang.org/x/tools/go/ast/astutil" + + "github.com/gnolang/gno/tm2/pkg/std" ) const ( @@ -150,7 +151,7 @@ func Precompile(source string, tags string, filename string) (*precompileResult, var out bytes.Buffer fset := token.NewFileSet() - f, err := parser.ParseFile(fset, "tmp.gno", source, parser.ParseComments) + f, err := parser.ParseFile(fset, filename, source, parser.ParseComments) if err != nil { return nil, fmt.Errorf("parse: %w", err) }