catala
catala copied to clipboard
Name resolution : precedence of local variables or scope variables ?
The problem
Consider the following program:
declaration scope X:
...
declaration scope Foo:
x scope X
internal y content integer
scope Foo:
definition y equals
let x equals 0 in
x + 1
What does the last x
refer to the local variable or the sub-scope ? Right now Catala's name resolution assigns x
to be the sub-scope, ignoring the local variable.
A fix
Local variables should always take precedence over scope variables in code, so surface/name_resolution.ml
should be changed to reflect that rule.
Ugh indeed!!
Added a related test in #319; but it seems to pass ??
That's weird. Moreover I can't find where I spotted this in the housing benefits examples. But we can add more unit tests to check for all kind of name precedence bugs in #319.