Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable shadowing and priorities #298

Open
brice-morin opened this issue Feb 25, 2020 · 0 comments
Open

Variable shadowing and priorities #298

brice-morin opened this issue Feb 25, 2020 · 0 comments

Comments

@brice-morin
Copy link
Collaborator

brice-morin commented Feb 25, 2020

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...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant