Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,7 @@ issues:
- path: _\.gno
linters:
- errorlint # Disabled linting of error comparisons, because of lacking std lib support
- path: gnovm/pkg/gnolang
text: "string `cross` has (\\d+) occurrences, make it a constant"
- path: gnovm/pkg/gnolang
text: "string `crossing` has (\\d+) occurrences, make it a constant"
2 changes: 2 additions & 0 deletions contribs/gnofaucet/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contribs/gnogenesis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ require (
golang.org/x/sys v0.32.0 // indirect
golang.org/x/term v0.31.0 // indirect
golang.org/x/text v0.24.0 // indirect
golang.org/x/tools v0.32.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
google.golang.org/grpc v1.69.4 // indirect
Expand Down
2 changes: 2 additions & 0 deletions contribs/gnogenesis/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contribs/gnokeykc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ require (
golang.org/x/sys v0.32.0 // indirect
golang.org/x/term v0.31.0 // indirect
golang.org/x/text v0.24.0 // indirect
golang.org/x/tools v0.32.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
google.golang.org/grpc v1.69.4 // indirect
Expand Down
2 changes: 2 additions & 0 deletions contribs/gnokeykc/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contribs/gnomigrate/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ require (
golang.org/x/sys v0.32.0 // indirect
golang.org/x/term v0.31.0 // indirect
golang.org/x/text v0.24.0 // indirect
golang.org/x/tools v0.32.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
google.golang.org/grpc v1.69.4 // indirect
Expand Down
2 changes: 2 additions & 0 deletions contribs/gnomigrate/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion examples/gno.land/r/jaekwon/dao/dao.gno
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package dao

import "fmt"
import (
"fmt"

"gno.land/p/demo/avl"
)

const (
DAONameLead = "lead"
Expand Down
6 changes: 4 additions & 2 deletions gnovm/pkg/gnolang/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ var (

// ReGnoRunPath is the path used for realms executed in maketx run.
// These are not considered realms, as an exception to the ReRealmPathPrefix rule.
var ReGnoRunPath = regexp.MustCompile(`^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.[a-zA-Z]{2,}/r/(?P<addr>g1[a-z0-9]+)/run$`)
var ReGnoRunPathAddrIndex = ReGnoRunPath.SubexpIndex("addr")
var (
ReGnoRunPath = regexp.MustCompile(`^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.[a-zA-Z]{2,}/r/(?P<addr>g1[a-z0-9]+)/run$`)
ReGnoRunPathAddrIndex = ReGnoRunPath.SubexpIndex("addr")
)

// IsRealmPath determines whether the given pkgpath is for a realm, and as such
// should persist the global state. These include temporary run realms.
Expand Down
9 changes: 1 addition & 8 deletions gnovm/pkg/gnolang/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -2021,13 +2021,6 @@ func (m *Machine) peekCallFrame(n int) *Frame {
// Returns the last defer call frame or nil.
func (m *Machine) LastDeferCallFrame() *Frame {
return &m.Frames[len(m.Frames)-1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops this isn't used, should be deleted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean to remove this line and revert the dead code I just deleted below?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, we should delete it, it isn't used at all.

for i := len(m.Frames) - 1; i >= 0; i-- {
fr := &m.Frames[i]
if fr.IsDefer {
return fr
}
}
return nil
}

// pops the last non-call (loop) frames
Expand Down Expand Up @@ -2109,7 +2102,7 @@ func (m *Machine) IsReadonly(tv *TypedValue) bool {
// Returns ro = true if the base is readonly,
// or if the base's storage realm != m.Realm and both are non-nil,
// and the lx isn't a name (base is a block),
// and the lx isn't a composit lit expr.
// and the lx isn't a composite lit expr.
func (m *Machine) PopAsPointer2(lx Expr) (pv PointerValue, ro bool) {
switch lx := lx.(type) {
case *NameExpr:
Expand Down
2 changes: 2 additions & 0 deletions gnovm/pkg/gnolang/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2321,6 +2321,7 @@ const (
underscoreResultNamePrefix = ".res_" // if was underscore
)

//nolint:unused
func isUnnamedResult(name Name) bool {
return isMissingResult(name) || isUnderscoreResult(name)
}
Expand All @@ -2329,6 +2330,7 @@ func isMissingResult(name Name) bool {
return strings.HasPrefix(string(name), missingResultNamePrefix)
}

//nolint:unused
func isUnderscoreResult(name Name) bool {
return strings.HasPrefix(string(name), underscoreResultNamePrefix)
}
3 changes: 3 additions & 0 deletions gnovm/pkg/gnolang/op_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (m *Machine) doOpPrecall() {

var gReturnStmt = &ReturnStmt{}

//nolint:unused
func getFuncTypeExprFromSource(source Node) *FuncTypeExpr {
if fd, ok := source.(*FuncDecl); ok {
return fd.GetUnboundTypeExpr()
Expand Down Expand Up @@ -432,6 +433,8 @@ func (m *Machine) doOpDefer() {
}

// XXX DEPRECATED
//
//nolint:govet // unreachable code
func (m *Machine) doOpPanic1() {
panic("doOpPanic1 is deprecated")
// Pop exception
Expand Down
3 changes: 2 additions & 1 deletion gnovm/pkg/gnolang/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ func initStaticBlocks(store Store, ctx BlockNode, bn BlockNode) {
idx := pkg.GetNumNames()
dname := Name(fmt.Sprintf("._%d", idx))
n.Name = dname

}
nx := &n.NameExpr
nx.Type = NameExprTypeDefine
Expand Down Expand Up @@ -2521,6 +2520,8 @@ func parseMultipleAssignFromOneExpr(
// We may still want this for optimizing heap defines;
// the current implementation of findHeapDefinesByUse/findHeapUsesDemoteDefines
// produces false positives.
//
//nolint:unused
func findGotoLoopDefines(ctx BlockNode, bn BlockNode) {
// create stack of BlockNodes.
var stack []BlockNode = make([]BlockNode, 0, 32)
Expand Down
1 change: 1 addition & 0 deletions gnovm/pkg/gnolang/uverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@ func makeUverseNode() {
panic("crossing could not find corresponding cross(fn)(...) call")
}
}
//nolint:govet // detected as unreachable
panic("should not happen") // defensive
},
)
Expand Down
6 changes: 3 additions & 3 deletions gnovm/pkg/gnolang/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ func (tv *TypedValue) SetReadonly(ro bool) {
tv.N = N_Readonly
return
} else {
return // perserve prior tv.N
return // preserve prior tv.N
}
}

Expand Down Expand Up @@ -2474,8 +2474,8 @@ type RefValue struct {
Hash ValueHash `json:",omitempty"`
}

func (ref RefValue) GetObjectID() ObjectID {
return ref.ObjectID
func (rv RefValue) GetObjectID() ObjectID {
return rv.ObjectID
}

// Base for a detached singleton (e.g. new(int) or &struct{})
Expand Down
3 changes: 1 addition & 2 deletions gnovm/pkg/test/filetest.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func (d Directives) FirstDefault(name, defaultValue string) string {
func (d Directives) FileTest() string {
var bld strings.Builder
for i, dir := range d {
var ll = ""
ll := ""
if i < len(d)-1 {
ll = "\n"
}
Expand Down Expand Up @@ -454,7 +454,6 @@ func ParseDirectives(source io.Reader) (Directives, error) {
if strings.HasPrefix(txt, "//") &&
strings.HasPrefix(last.LastLine, "//") &&
!last.Complete {

if last.Name == "" {
// Just append text to it.
last.Content += txt + "\n"
Expand Down
6 changes: 4 additions & 2 deletions gnovm/stdlibs/std/emit_event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import (
"github.com/stretchr/testify/assert"
)

const pkgPath = "emit_test"
const fileName = "emit_test.gno"
const (
pkgPath = "emit_test"
fileName = "emit_test.gno"
)

var line = 1

Expand Down
4 changes: 2 additions & 2 deletions gnovm/stdlibs/std/native.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func X_getRealm(m *gno.Machine, height int) (address, pkgPath string) {

var (
ctx = GetContext(m)
crosses int // track realm crosses
lfr *gno.Frame = m.LastFrame() // last call frame
lfr = m.LastFrame() // last call frame
crosses int // track realm crosses
)

for i := m.NumFrames() - 1; i >= 0; i-- {
Expand Down
5 changes: 2 additions & 3 deletions gnovm/tests/stdlibs/std/std.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ func X_getRealm(m *gno.Machine, height int) (address string, pkgPath string) {

var (
ctx = m.Context.(*TestExecContext)
crosses int // track realm crosses
lfr *gno.Frame = m.LastFrame() // last call frame
lfr = m.LastFrame() // last call frame
crosses int // track realm crosses
)

for i := m.NumFrames() - 1; i >= 0; i-- {
Expand Down Expand Up @@ -163,7 +163,6 @@ func X_getRealm(m *gno.Machine, height int) (address string, pkgPath string) {
default:
panic("exec kind unspecified")
}

}

func X_isRealm(m *gno.Machine, pkgPath string) bool {
Expand Down
1 change: 1 addition & 0 deletions misc/autocounterd/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ require (
golang.org/x/sys v0.32.0 // indirect
golang.org/x/term v0.31.0 // indirect
golang.org/x/text v0.24.0 // indirect
golang.org/x/tools v0.32.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
google.golang.org/grpc v1.69.4 // indirect
Expand Down
4 changes: 1 addition & 3 deletions misc/docs/tools/indexparser/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ type (
}
)

var (
rootFlagSet = flag.NewFlagSet("parser", flag.ExitOnError)
)
var rootFlagSet = flag.NewFlagSet("parser", flag.ExitOnError)

func parseRootConfig(args []string) (*RootConfig, error) {
var cfg RootConfig
Expand Down
3 changes: 3 additions & 0 deletions misc/genstd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ run:

test:
go test -v .

test.update:
go test -v . -update-golden-tests
9 changes: 8 additions & 1 deletion misc/genstd/genstd_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package main

import (
"flag"
"os"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

var update = flag.Bool("update-golden-tests", false, "update golden test files")

func TestIntegration(t *testing.T) {
chdir(t, "testdata/integration")
skipExternalTools = true
Expand All @@ -22,5 +25,9 @@ func TestIntegration(t *testing.T) {
want, err := os.ReadFile("generated.go.golden")
require.NoError(t, err)

assert.Equal(t, string(want), string(got))
if *update {
require.NoError(t, os.WriteFile("generated.go.golden", got, 0o644))
} else {
assert.Equal(t, string(want), string(got))
}
}
2 changes: 1 addition & 1 deletion misc/genstd/testdata/integration/generated.go.golden
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var nativeFuncs = [...]NativeFunc{
[]gno.FieldTypeExpr{
},
[]gno.FieldTypeExpr{
{Name: gno.N("r0"), Type: gno.X("int")},
{NameExpr: *gno.Nx("r0"), Type: gno.X("int")},
},
true,
func(m *gno.Machine) {
Expand Down
1 change: 1 addition & 0 deletions misc/loop/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ require (
golang.org/x/term v0.31.0 // indirect
golang.org/x/text v0.24.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.32.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
google.golang.org/grpc v1.69.4 // indirect
Expand Down
2 changes: 2 additions & 0 deletions misc/loop/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions misc/stdlib_diff/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func NewReportBuilder(srcPath, dstPath, outDir string) (*ReportBuilder, error) {
return nil, err
}

//filepath.EvalSymlinks will return the original path if there are no simlinks associated to the given path
// filepath.EvalSymlinks will return the original path if there are no simlinks associated to the given path
realSrcPath, err := filepath.EvalSymlinks(srcPath)
if err != nil {
return nil, err
Expand All @@ -84,7 +84,7 @@ func NewReportBuilder(srcPath, dstPath, outDir string) (*ReportBuilder, error) {
return nil, err
}
// Create output if not exist
err = os.MkdirAll(outDir, 0777)
err = os.MkdirAll(outDir, 0o777)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -187,7 +187,6 @@ type Directory struct {
// listDirectories retrieves a list of directories in the source path.
func (builder *ReportBuilder) listDirectories() ([]*Directory, error) {
allSubdirectories, srcDirectories, destDirectories, err := builder.findDirectories()

if err != nil {
return nil, err
}
Expand Down Expand Up @@ -227,12 +226,15 @@ func (builder *ReportBuilder) listDirectories() ([]*Directory, error) {

return res, err
}

func isRootFolder(path string) bool {
return !strings.Contains(path, "/")
}

func getRootFolder(path string) string {
return strings.Split(path, "/")[0]
}

func (builder *ReportBuilder) getAllSubdirectories(rootPath string) ([]string, error) {
directories := make([]string, 0)
err := filepath.WalkDir(rootPath, func(path string, dirEntry fs.DirEntry, err error) error {
Expand All @@ -256,7 +258,7 @@ func (builder *ReportBuilder) writeIndexTemplate(data *IndexTemplate) error {
return err
}

if err := os.WriteFile(builder.OutDir+"/index.html", resolvedTemplate.Bytes(), 0644); err != nil {
if err := os.WriteFile(builder.OutDir+"/index.html", resolvedTemplate.Bytes(), 0o644); err != nil {
return err
}

Expand All @@ -271,11 +273,11 @@ func (builder *ReportBuilder) writePackageTemplate(templateData any, packageName
return err
}

if err := os.MkdirAll(builder.OutDir+"/"+packageName, 0777); err != nil {
if err := os.MkdirAll(builder.OutDir+"/"+packageName, 0o777); err != nil {
return err
}

if err := os.WriteFile(builder.OutDir+"/"+packageName+"/report.html", resolvedTemplate.Bytes(), 0644); err != nil {
if err := os.WriteFile(builder.OutDir+"/"+packageName+"/report.html", resolvedTemplate.Bytes(), 0o644); err != nil {
return err
}

Expand Down
Loading
Loading