Module: Jade::Frontend::SemanticAnalysis::TypeDeclaration

Extended by:
Helper, TypeDeclaration
Included in:
TypeDeclaration
Defined in:
lib/jade/frontend/semantic_analysis/type_declaration.rb

Instance Method Summary collapse

Methods included from Helper

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

Instance Method Details

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



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/jade/frontend/semantic_analysis/type_declaration.rb', line 8

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

  symbol_ref = entry.lookup_type(name).to_ref

  analyze_in_parallel(variants, registry, scope, entry)
    .then { Result.combine(node, scope:, variants: it) }
    .map_node { it.with(symbol: symbol_ref) }
    .add_errors(validate_no_unbound_vars(symbol_ref, registry, entry))
    .add_errors(validate_type_symbol(symbol_ref, registry, entry))
end