Skip to content

Commit 825d63b

Browse files
committed
refactor(interpreter): use env instead of values for package storage
The change replaces direct access to `values` with the `env` field for storing and retrieving package constants. This provides better consistency with how other package data is accessed and makes the code more maintainable.
1 parent bf3420e commit 825d63b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/interpreter/interpreter.mbt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ pub fn ClosureInterpreter::top_visit(
266266
// 处理顶层常量定义(如 const Zero = 0)
267267
TopLetDef(binder~, expr~, ..) => {
268268
let value = self.visit(expr) catch { _ => Unit }
269-
self.current_pkg.values.set(binder.name, value)
269+
let name = binder.name
270+
self.current_pkg.env.set(name, value)
270271
value
271272
}
272273
TopTypeDef(def) => {
@@ -786,7 +787,10 @@ pub fn ClosureInterpreter::visit(
786787
self.find_pkg(pkg).env
787788
.find(name)
788789
.unwrap_or(self.current_pkg.cons(name, []))
789-
_ => self.current_pkg.cons(name, [])
790+
_ =>
791+
self.current_pkg.env
792+
.find(name)
793+
.unwrap_or(self.current_pkg.cons(name, []))
790794
}
791795
}
792796
// 处理 Break 表达式

0 commit comments

Comments
 (0)