Class: Rigor::Inference::Fallback
- Inherits:
-
Object
- Object
- 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 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 |