From b6270572903a6a463efb2584bfc6baff675e1647 Mon Sep 17 00:00:00 2001 From: Diego Augusto Molina Date: Sat, 27 Sep 2025 16:15:25 -0300 Subject: [PATCH] make ast.Node return *nature.Nature --- ast/node.go | 6 +++--- checker/checker.go | 3 +-- checker/info.go | 3 +-- compiler/compiler.go | 3 +-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ast/node.go b/ast/node.go index 40c507aa6..f156f69be 100644 --- a/ast/node.go +++ b/ast/node.go @@ -15,7 +15,7 @@ var ( type Node interface { Location() file.Location SetLocation(file.Location) - Nature() nature.Nature + Nature() *nature.Nature SetNature(nature.Nature) Type() reflect.Type SetType(reflect.Type) @@ -47,8 +47,8 @@ func (n *base) SetLocation(loc file.Location) { } // Nature returns the nature of the node. -func (n *base) Nature() nature.Nature { - return n.nature +func (n *base) Nature() *nature.Nature { + return &n.nature } // SetNature sets the nature of the node. diff --git a/checker/checker.go b/checker/checker.go index 531dadac3..e1d1f90a6 100644 --- a/checker/checker.go +++ b/checker/checker.go @@ -635,8 +635,7 @@ func (v *Checker) callNode(node *ast.CallNode) Nature { // checker pass we should replace anyType on method node // with new correct function return type. if typ := node.Type(); typ != nil && typ != anyType { - nt := node.Nature() - return nt + return *node.Nature() } nt := v.visit(node.Callee) diff --git a/checker/info.go b/checker/info.go index 1b0e05100..57202e958 100644 --- a/checker/info.go +++ b/checker/info.go @@ -15,8 +15,7 @@ func FieldIndex(c *Cache, env Nature, node ast.Node) (bool, []int, string) { return true, idx, n.Value } case *ast.MemberNode: - base := n.Node.Nature() - base = base.Deref(c) + base := n.Node.Nature().Deref(c) if base.Kind == reflect.Struct { if prop, ok := n.Property.(*ast.StringNode); ok { if idx, ok := base.FieldIndex(c, prop.Value); ok { diff --git a/compiler/compiler.go b/compiler/compiler.go index c7469030c..83b19a885 100644 --- a/compiler/compiler.go +++ b/compiler/compiler.go @@ -1088,8 +1088,7 @@ func (c *compiler) BuiltinNode(node *ast.BuiltinNode) { for i, arg := range node.Arguments { c.compile(arg) argType := arg.Type() - argNature := arg.Nature() - if argType.Kind() == reflect.Ptr || argNature.IsUnknown(c.ntCache) { + if argType.Kind() == reflect.Ptr || arg.Nature().IsUnknown(c.ntCache) { if f.Deref == nil { // By default, builtins expect arguments to be dereferenced. c.emit(OpDeref)