Class: Rigor::TypeNode::StringLiteral
- Inherits:
-
Object
- Object
- Rigor::TypeNode::StringLiteral
- Defined in:
- lib/rigor/type_node/string_literal.rb
Overview
String-literal AST node. Used as a Generic#args entry for parametric forms whose argument is a String literal — namely ‘Pick[T, “name”]`, `pick_of[Shape, “a” | “b”]`, and downstream plugin resolvers that accept literal key selectors.
ADR-13 follow-up (‘docs/CURRENT_WORK.md` engineering item #2): the RBS::Extended grammar previously could not tokenise `“name”` inside a type-arg position. The resolver translates this node to a `Type::Constant` carrying the string value. Slice 1 supports double-quoted strings without escape sequences (the most common shape — TS-style key unions are bare identifier-ish names).
Instance Method Summary collapse
-
#initialize(value:) ⇒ StringLiteral
constructor
A new instance of StringLiteral.
Constructor Details
#initialize(value:) ⇒ StringLiteral
Returns a new instance of StringLiteral.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rigor/type_node/string_literal.rb', line 18 def initialize(value:) unless value.is_a?(String) raise ArgumentError, "TypeNode::StringLiteral value must be a String, " \ "got #{value.inspect}" end # Freeze the String field so the Data object is # `Ractor.shareable?` regardless of caller frozen- # string-literal state. super(value: value.frozen? ? value : value.dup.freeze) end |