Dictu icon indicating copy to clipboard operation
Dictu copied to clipboard

Fix a niche issue with global shadowing

Open Jason2605 opened this issue 3 years ago • 1 comments

Well detailed description of the change :

This change makes it so that shadowing a builtin in the module level space has the same effect as shadowing a builtin in the local level space. Previously setting a variable with an identifier of a builtin (e.g input) in the module level space would keep the value of the builtin value rather than taking the new value of the variable. Shadowing should be avoided, but this at least keeps the scoping consistent.

Resolves: #341

Type of change:

  • [x] Bug fix

Housekeeping

  • [x] Tests have been updated to reflect the changes done within this PR (if applicable).

  • [x] Documentation has been updated to reflect the changes done within this PR (if applicable).

Jason2605 avatar May 03 '22 12:05 Jason2605

This will need revising, tested via the REPL and works, however, executing a file it will not work. This is due to the fact that the variable would not have been added to the VM module until runtime and we are checking at compile time. Works in the REPL as each line is a new compilation

Jason2605 avatar May 03 '22 13:05 Jason2605

Hi (again), I have a similar issue also in my little language. The problem isn't really in the search of the variable, but more of how var declaration works, since it always leads to a module definition (or local), so it creates the variable at module scope, but it will always be shadowed by the global definition. Or at least, that's what I was thinking.

RevengerWizard avatar Nov 22 '22 14:11 RevengerWizard