Class: Rigor::Inference::Fallback
- Inherits:
-
Object
- Object
- Rigor::Inference::Fallback
- Defined in:
- lib/rigor/inference/fallback.rb,
sig/rigor/inference.rbs
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 ⇒ Symbol
readonly
Returns the value of attribute family.
-
#inner_type ⇒ Type::t
readonly
Returns the value of attribute inner_type.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#node_class ⇒ Class
readonly
Returns the value of attribute node_class.
Instance Method Summary collapse
-
#initialize(node_class:, location:, family:, inner_type:, origin: nil) ⇒ Fallback
constructor
A new instance of Fallback.
Constructor Details
#initialize(node_class:, location:, family:, inner_type:, origin: nil) ⇒ Fallback
Returns a new instance of Fallback.
20 21 22 23 24 25 26 27 28 |
# File 'lib/rigor/inference/fallback.rb', line 20 def initialize(node_class:, location:, family:, inner_type:, origin: nil) 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 ⇒ Symbol (readonly)
Returns the value of attribute family.
142 143 144 |
# File 'sig/rigor/inference.rbs', line 142 def family @family end |
#inner_type ⇒ Type::t (readonly)
Returns the value of attribute inner_type.
143 144 145 |
# File 'sig/rigor/inference.rbs', line 143 def inner_type @inner_type end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
141 142 143 |
# File 'sig/rigor/inference.rbs', line 141 def location @location end |
#node_class ⇒ Class (readonly)
Returns the value of attribute node_class.
140 141 142 |
# File 'sig/rigor/inference.rbs', line 140 def node_class @node_class end |