Module: Jade::Frontend::SemanticAnalysis::VariableReference

Extended by:
Helper, VariableReference
Included in:
VariableReference
Defined in:
lib/jade/frontend/semantic_analysis/variable_reference.rb

Instance Method Summary collapse

Methods included from Helper

analyze_duplicate_fields, analyze_in_parallel, analyze_in_sequence, analyze_node, bind, collect_vars, lookup, validate_type_symbol

Instance Method Details

#analyze(node, _registry, scope, entry) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/jade/frontend/semantic_analysis/variable_reference.rb', line 8

def analyze(node, _registry, scope, entry)
  node => AST::VariableReference(name:)

  case scope.lookup(name)
  in nil
    Result
      .init(node.with(symbol: Symbol.var(name, node.range)), scope)
      .add_errors([Error::UndefinedVariable.new(
        entry.name, node.range, var_ref: name,
        candidates: scope.bindings.keys,
      )])

  in symbol
    Result.init(node.with(symbol:), scope)
  end
end