Class: Rigor::Inference::Fallback

Inherits:
Data
  • Object
show all
Defined in:
lib/rigor/inference/fallback.rb

Overview

Immutable value object recorded by the typer whenever Scope#type_of falls back to Dynamic for a node it does not yet recognise. The contract for emitting these events lives in docs/internal-spec/inference-engine.md (Fail-Soft Policy).

Fields:

  • node_class: the Ruby class of the node that triggered the fallback (e.g. Prism::CallNode, or a Rigor::AST::Node subclass).

  • location: the Prism source location for real Prism nodes, or nil for synthetic nodes.

  • family: :prism for real Prism nodes, :virtual for nodes that include Rigor::AST::Node.

  • inner_type: the Rigor::Type returned to the caller (currently always Dynamic; later slices may carry richer fallback types).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node_class:, location:, family:, inner_type:) ⇒ Fallback

Returns a new instance of Fallback.

Raises:

  • (ArgumentError)


24
25
26
27
28
29
30
31
32
# File 'lib/rigor/inference/fallback.rb', line 24

def initialize(node_class:, location:, family:, inner_type:)
  raise ArgumentError, "node_class must be a Class, got #{node_class.class}" unless node_class.is_a?(Class)

  unless FALLBACK_FAMILIES.include?(family)
    raise ArgumentError, "family must be one of #{FALLBACK_FAMILIES.inspect}, got #{family.inspect}"
  end

  super
end

Instance Attribute Details

#familyObject (readonly)

Returns the value of attribute family

Returns:

  • (Object)

    the current value of family



23
24
25
# File 'lib/rigor/inference/fallback.rb', line 23

def family
  @family
end

#inner_typeObject (readonly)

Returns the value of attribute inner_type

Returns:

  • (Object)

    the current value of inner_type



23
24
25
# File 'lib/rigor/inference/fallback.rb', line 23

def inner_type
  @inner_type
end

#locationObject (readonly)

Returns the value of attribute location

Returns:

  • (Object)

    the current value of location



23
24
25
# File 'lib/rigor/inference/fallback.rb', line 23

def location
  @location
end

#node_classObject (readonly)

Returns the value of attribute node_class

Returns:

  • (Object)

    the current value of node_class



23
24
25
# File 'lib/rigor/inference/fallback.rb', line 23

def node_class
  @node_class
end