Retoor software development Projects Research SearchXNG
Register Sign In

10 lines
245 B
Plaintext
Raw Normal View History

feat: add block scope support with push/pop macros and scope tracking in compiler Introduce Scope struct and PUSH_SCOPE/POP_SCOPE macros to manage nested variable scopes during compilation. Update declareVariable to distinguish global declarations from local ones based on scope presence rather than parent compiler. Add truncateSymbolTable helper to clean up local symbols when exiting a scope. Include new test files verifying scoped variable isolation in if, while, and block constructs.
2013-11-18 18:19:03 +01:00
// Create a local scope for the 'then' expression.
var a = "out"
if (true) var a = "in"
io.write(a) // expect: out
// Create a local scope for the 'else' expression.
var b = "out"
if (false) "dummy" else var b = "in"
io.write(b) // expect: out
Reference in New Issue Copy Permalink
f9c534aef9
wren/test/variable/scope_if.wren
Response time: 88ms
Mail Licenses API