Class: Rigor::Inference::Fallback
- Inherits:
-
Data
- Object
- Data
- Rigor::Inference::Fallback
- 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
-
#family ⇒ Object
readonly
Returns the value of attribute family.
-
#inner_type ⇒ Object
readonly
Returns the value of attribute inner_type.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#node_class ⇒ Object
readonly
Returns the value of attribute node_class.
Instance Method Summary collapse
-
#initialize(node_class:, location:, family:, inner_type:) ⇒ Fallback
constructor
A new instance of Fallback.
Constructor Details
#initialize(node_class:, location:, family:, inner_type:) ⇒ Fallback
Returns a new instance of Fallback.
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
#family ⇒ Object (readonly)
Returns the value of attribute family
23 24 25 |
# File 'lib/rigor/inference/fallback.rb', line 23 def family @family end |
#inner_type ⇒ Object (readonly)
Returns the value of attribute inner_type
23 24 25 |
# File 'lib/rigor/inference/fallback.rb', line 23 def inner_type @inner_type end |
#location ⇒ Object (readonly)
Returns the value of attribute location
23 24 25 |
# File 'lib/rigor/inference/fallback.rb', line 23 def location @location end |
#node_class ⇒ Object (readonly)
Returns the value of attribute node_class
23 24 25 |
# File 'lib/rigor/inference/fallback.rb', line 23 def node_class @node_class end |