-
Notifications
You must be signed in to change notification settings - Fork 308
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
Add tracking function name for void feature at the compiler #478
base: main
Are you sure you want to change the base?
Conversation
To clarify the semantic error with |
Thanks for raising this! I'm not entirely sure I understand the issue. What is the AST that our parser generates for:
? The way we handle
(i.e. we generate a void expression for the variable holding the function, not for the function expression)? I think this is almost correct since in both cases the call to
Because we'll turn it into
And now it suddenly works. I guess the problem here is to some degree that our IL cannot distinguish between function expressions (what comes after the |
Hi @saelo, thanks so much for your review. Given the input below:
The AST is as follows, where I added the function name. This fixed the error because previously there was no name for the function expression in the AST. That’s why when calling test(), the incorrect function was called.
|
I also agree with the fix for the JavaScript lifter for |
Hi, I found an error in the
void
compilation as follows.When
void
is suffixed to a function expression, and that function is called again later, the compiler will not retain information about the void function. As a result, it will create a call to a new named function as follows:will be compiled incorrectly into:
I fixed this by adding the function name to the AST structure, enabling the compiler to track it. Please see the corrected compilation output below:
I also identified a semantic error with
void
in the FuzzIL and JavaScript lifters as follows:Here, we add
void
tof8()
, then execute the functionf8
. The string1
is printed, which is semantically incorrect sincef8()
is avoid
function and should returnundefined
. I think thevoid
keyword should be lifted together with the function definition to be semantically correct somehow. This semantic error has not been addressed in this PR.