-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description:
Currently, variable shadowing within functions does not work correctly. A local variable that has the same name as an outer variable incorrectly overrides the outer variable across all scopes, rather than being limited to the inner block.
Example:
let x = 10 in
let add() {
let x = 20 in
x
}
print(add() + x)
Expected Behavior:
This should print 30 because:
add()returns the innerx(20).- The outer
xremains10. - Therefore,
20 + 10 = 30.
Actual Behavior:
Instead, it prints 40. The inner x (20) shadows the outer x everywhere, causing the calculation to become 20 + 20.
Impact:
This behavior breaks proper lexical scoping rules, making it impossible to reliably shadow variables without affecting the outer scopes.
Steps to Reproduce:
- Declare a variable in an outer scope.
- Create a function that contains a variable with the same name.
- Attempt to access both the inner and outer variables.
- Observe that the shadowed variable incorrectly affects the outer scope.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
In progress