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

ASL: ASL v0 implicit declarations must be hoisted to highest legal scope #692

Closed
arm-chrjan01 opened this issue Oct 9, 2023 · 2 comments

Comments

@arm-chrjan01
Copy link

The approach used to handle ASL v0 implicit declarations is incorrect.

If a statement assigns to a variable that has not been explicitly declared, then the assignment is treated as an implicit declaration of that variable provided that the following conditions hold:

  • It is possible to infer the type of the variable.
  • It would be possible to insert a single explicit declaration before the assignment that would give the variable the same type.

The scope of the variable is the broadest scope consistent with the above rules.

That is, it is treated as if a single explicit declaration had been inserted at the outermost legal scope.

It is not always possible to place an explicit declaration in the outermost scope because the type of an implicitly declared variable may depend on a variable that is only exists in an inner scope or that is modified between the outermost scope and the location of the assignment to the implicitly declared variable.

@HadrienRenaud
Copy link
Collaborator

Hi @arm-chrjan01,

Thank you for your feedback. I'm not sure I understand your remark, especially when it comes to scopes. Could you provide an example?

Furthermore, in our implementation, I think the scope of the declaration is the scope of the first implicit assignment. For example:

func foo() begin
  for i = 3 to 21 do
     my_impl_decl_var = FALSE;
  end
  // my_impl_decl_var is not in scope here
end

Is this the expected behaviour?

@jalglave
Copy link
Member

Moving ASLRef.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants