From d62656c615eab4dbef7145d979c98851c73eb9b4 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 22 Oct 2025 14:55:49 -0400 Subject: [PATCH] interpret: Properly scope enum variants! --- compiler/cl-interpret/src/interpret.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/cl-interpret/src/interpret.rs b/compiler/cl-interpret/src/interpret.rs index 7409999..69068fe 100644 --- a/compiler/cl-interpret/src/interpret.rs +++ b/compiler/cl-interpret/src/interpret.rs @@ -189,7 +189,12 @@ impl Interpret for Enum { } (StructKind::Tuple(args), None) => { let cs = Constructor { arity: args.len() as _, name: *name }; - scope.insert("call".into(), ConValue::TupleConstructor(cs)); + let mut variant = scope.frame(name.to_ref()); + variant.insert("call".into(), ConValue::TupleConstructor(cs)); + let frame = variant + .pop_values() + .expect("Frame stack should remain balanced."); + scope.insert(*name, ConValue::Module(Box::new(frame))); } (StructKind::Struct(_), None) => {} _ => eprintln!("Well-formedness error in {self}"),