flofriday / Moose

🐐 A new fun programming language
MIT License
6 stars 1 forks source link

Variable name collision #12

Closed flofriday closed 2 years ago

flofriday commented 2 years ago

Example

func inner() {
    x = 8000
}

func outer() > Int {
    x = 3
    inner()
    return x
}

print(outer) // prints 8000 instead of 3

Reason

So when we call a function we stack a new environment ontop the current one. This is wrong we should stack the new environment ontop of the global one.

flofriday commented 2 years ago

Is now fixed