Variable shadowing and priorities
brice-morin opened this issue · comments
Consider the following ThingML function:
function f(a : Integer) do
var b : Integer = a - 1
...
var a : Integer = 0
...
end
The parser does not complain, but yields a surprising result...
In b = a - 1
, a
refers to var a
, which is declared afterwards. IMHO, it should refer to the parameter a
of the function, since it has not been shadowed yet.... Anyway, I think:
- shadowing is dangerous and should not be allowed i.e., it should not be possible to declare
var a
if it has been previously declared in a variable or a parameter. - in an action block, it should not be possible to refer to variables defined later on... action blocks being purely sequential...