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

Emit discard instructions after a statement-level function call #9

Open
vendethiel opened this issue Jan 17, 2023 · 1 comment
Open

Comments

@vendethiel
Copy link
Member

All functions should emit something, even if the last instruction in any function is pushundef, which would be a marker "This is not supposed to be read!" value.
Then, when statement-level function calls happen, we should emit a call + discard (or a different instruction like sinkcall, or a flag in the Call for the VM).
On the other hand, if a function didn't return, then the VM will read that "undef" value and should error that it was used as a value ("Procedure used as value" or something).

We'll definitely want much, much later to know the prototypes of the functions we call to make sure this doesn't happen, but that's too big a task for now, and I'd rather not add a null/undefined value to the language at all.

@vendethiel
Copy link
Member Author

Apparently LLVM does something similar-ish. We could name our special value "poison" or something similar. An array can suffice as a Maybe for now.

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

1 participant