Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🪲 Add support for local scopes in the lookup table (#5793)
This PR adds introduces support for local scopes. It is a naive implementation that relies on the fact that we cannot nest functions. Thus, every line of code can either be in one local scope of in the global scope. Functions are the only exception - they must be accessible in the global scope and their own local scope (because we have support for recursion). Fixes #5728 **How to test** Execute programs in level 12 that introduce a clash between local and global scope, e.g. a variable only defined in local scope is used in the global, or a global and a local variables with the same name but only one of them is used should generate an unused var warning for the right variable. Here are some scenarios: ``` define add x is 1 print x call add print x # must produce an error on line 5 ``` ``` define add print x x is 5 call add # must produce an error on line 2 ``` ``` x is 5 define add print x call add # must correctly print 5 because the part of the global scope is provided in the closure ``` ``` define add x is 5 x is 10 print x call add # must produce a warning for line 2 ``` ``` define add x is 5 print x x is 10 call add # must produce a warning for line 4 ```
- Loading branch information