TelluIoT / ThingML

The ThingML modelling language
https://github.com/TelluIoT/ThingML
Apache License 2.0
103 stars 32 forks source link

Variable shadowing and priorities #298

Open brice-morin opened 4 years ago

brice-morin commented 4 years ago

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: