https://toitlang.org/ logo
I'm trying to figure out some behavior that I'm no...
# general
n
I'm trying to figure out some behavior that I'm not understanding. I have the following classes:
Copy code
// Base class for all AST nodes.
class AstNode:
  line_/int
  col_/int

  constructor .line_ .col_:

  // A simple stringify for debugging.
  // Subclasses should override this.
  stringify -> string:
    return "AST Node: ($line_:$col_)"


// --- File Nodes ---

class LibFileNode extends AstNode:
  entries/List // List<NamedSpecNode | NamedDataNode>

  constructor line_/int col_/int .entries:
    super line_ col_
  
  stringify -> string:
    return "LibFileNode: entries:$entries"
When I run a parsing function that returns an instance, called
result
of
LibFileNode
I can validate this with
result is LibFileNode
which does return
true
, however if I try and run
print result.entries
I get an error saying:
Copy code
error: Class 'AstNode' does not have any method 'entries'
Shouldn't the
Instance.field
getter work by default?