Class: Rigor::TypeNode::IndexedAccess
- Inherits:
-
Object
- Object
- Rigor::TypeNode::IndexedAccess
- Defined in:
- lib/rigor/type_node/indexed_access.rb
Overview
AST wrapper for the trailing ‘T` indexed-access projection chain. The parser emits a left-associative chain by wrapping the receiver AST in successive `IndexedAccess` nodes (`Tuple[A, B][0]` parses to `IndexedAccess(IndexedAccess(Generic(Tuple, [A, B]), 1), 0)`).
‘receiver` and `key` are themselves any AST node — the indexed-access chain is applied at resolution time, after the receiver has been resolved to a Rigor::Type carrier and the key has been resolved (typically to a `Constant<Integer>` or a constant String/Symbol singleton).
Instance Method Summary collapse
-
#initialize(receiver:, key:) ⇒ IndexedAccess
constructor
A new instance of IndexedAccess.
Constructor Details
#initialize(receiver:, key:) ⇒ IndexedAccess
Returns a new instance of IndexedAccess.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rigor/type_node/indexed_access.rb', line 17 def initialize(receiver:, key:) unless valid_node?(receiver) raise ArgumentError, "TypeNode::IndexedAccess receiver must be a TypeNode " \ "node, got #{receiver.inspect}" end unless valid_node?(key) raise ArgumentError, "TypeNode::IndexedAccess key must be a TypeNode " \ "node, got #{key.inspect}" end super end |