-
Notifications
You must be signed in to change notification settings - Fork 8
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
Function in session is called incorrectly in generated code #763
Comments
I also noticed this recently. The issue seems to be that the parser doesn't recognize the expression "Valid_Func" as a call, but as a variable. So it generates "Obj := Valid_Func;" which would be correct if Valid_Func was a variable, instead of Valid_Func (Obj) which is needed if it's a function call. |
While this is obviously a parser issue, I wonder whether we want to support this kind of usage. It implies that the function is either completely static or uses some undefined global state. I could imagine that this could cause some trouble in the generated SPARK code, too. @treiher, what do you think? |
The parser is unable to differentiate a variable from a function call with no parameters, as both cases are syntactically identical. The semantics can be just determined after parsing during semantic analysis (model generation).
I think there are use cases for such functions, e.g., for supplying configuration values to the generated SPARK code. |
When a function is passed to a session and used as in this example:
the generated code expects a procedure but calls this procedure as if it was a function:
This leads to the following error:
The text was updated successfully, but these errors were encountered: