make ast.Node return *nature.Nature (#849)

This commit is contained in:
Diego Augusto Molina
2025-09-29 11:10:45 +02:00
committed by GitHub
parent 93c6e39251
commit 6b6df6494c
4 changed files with 6 additions and 9 deletions
+3 -3
View File
@@ -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.
+1 -2
View File
@@ -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)
+1 -2
View File
@@ -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 {
+1 -2
View File
@@ -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)