pub enum MirConstant {
Int(i64),
Bool(bool),
None,
StringId(u32),
Str(String),
Float(u64),
Decimal(String),
Char(char),
Function(String),
Method(String),
ClosurePlaceholder,
}Expand description
A constant value in MIR.
Variants§
Int(i64)
Bool(bool)
None
StringId(u32)
String interned index (legacy — prefer Str for new code)
Str(String)
String literal value (carried through MIR for direct JIT materialization)
Float(u64)
Float (stored as bits for Eq/Hash)
Decimal(String)
Decimal literal — carried through MIR as the source-form lexeme.
WS-8 (2026-05-22): pre-WS-8 Literal::Decimal(_) MIR lowering at
mir/lowering/expr.rs:1937 collapsed to MirConstant::Float(0) (“decimal
not yet modeled”), silently losing the value. The JIT then printed
0.0 for print(1.5D) while the VM printed 1.5D — a v0.3-gating
silent wrong-answer divergence (WS-8 audit §1.D). The MIR producer now
emits this variant verbatim; the JIT consumer SURFACEs (compile_constant
returns Err), triggering the W12 fall-through to the bytecode interpreter
(which materializes the decimal via the VM’s NewDecimalV2 opcode and
prints correctly). VM == JIT, both run the interpreter path. The variant
stores the decimal’s lexeme so JIT codegen can light up later without
re-parsing the AST.
Char(char)
Character literal (scalar codepoint).
Phase 3 cluster-2 Round 4 cw-D-fam12 follow-up (instance 57, 2026-05-16).
ADR-006 §2.7.5 amendment Round 19 S1.5 W12-nativekind-scalar-additions
(2026-05-14): Char is a 4-byte scalar NativeKind variant (codepoint
in low 32 bits of ValueSlot, no Arc wrapping). Producing-site
stamp-at-compile-time discipline requires the MIR layer to preserve the
Char kind through to the JIT’s operand_slot_kind / infer_constant_kind
classifiers — otherwise Literal::Char('A') is lost as MirConstant::Int(65)
at MIR lowering, the JIT stamps NativeKind::Int64, and the print
dispatch matches print_i64(65) instead of print_char(65) → JIT prints
“65” while VM prints “A” (cw-D-fam12 Char production-fixture divergence).
Function(String)
Function reference by name
Method(String)
Method name for dispatch
ClosurePlaceholder
Placeholder for a closure function reference.
Patched to Function(name) after bytecode compilation resolves the closure’s function_id.
Trait Implementations§
Source§impl Clone for MirConstant
impl Clone for MirConstant
Source§fn clone(&self) -> MirConstant
fn clone(&self) -> MirConstant
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MirConstant
impl Debug for MirConstant
Source§impl Display for MirConstant
impl Display for MirConstant
Source§impl Hash for MirConstant
impl Hash for MirConstant
Source§impl PartialEq for MirConstant
impl PartialEq for MirConstant
Source§fn eq(&self, other: &MirConstant) -> bool
fn eq(&self, other: &MirConstant) -> bool
self and other values to be equal, and is used by ==.impl Eq for MirConstant
impl StructuralPartialEq for MirConstant
Auto Trait Implementations§
impl Freeze for MirConstant
impl RefUnwindSafe for MirConstant
impl Send for MirConstant
impl Sync for MirConstant
impl Unpin for MirConstant
impl UnsafeUnpin for MirConstant
impl UnwindSafe for MirConstant
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.