Module: Jade::Frontend::SemanticAnalysis::ConstructorReference

Extended by:
ConstructorReference, Helper
Included in:
ConstructorReference
Defined in:
lib/jade/frontend/semantic_analysis/constructor_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
24
25
26
27
28
29
30
31
32
# File 'lib/jade/frontend/semantic_analysis/constructor_reference.rb', line 8

def analyze(node, registry, scope, entry)
  node => AST::ConstructorReference(name:)

  symbol = scope.lookup(name) || resolve_private_constructor(name, registry)

  case symbol
  in nil
    (tuple_arity_overflow(name, entry, node.range) ||
      Error::ConstructorNotFound.new(
        entry.name,
        node.range,
        name:,
        exposed_type_module: exposed_type_origin(name, entry, registry),
        candidates: scope.bindings.keys.select { it.match?(/\A[A-Z]/) },
      ))
      .then do
        Result
          .init(node, scope)
          .add_errors([it])
      end

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