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

Require main to always return unit #551

Merged
merged 5 commits into from
Aug 22, 2024
Merged

Require main to always return unit #551

merged 5 commits into from
Aug 22, 2024

Conversation

b-studios
Copy link
Collaborator

In the LLVM backend, we experienced problems with boxing of the result of main. Here, we require that main always returns Unit and check this.

Related to #541

@b-studios
Copy link
Collaborator Author

This breaks effekt.WebTests since they rely on the (only) exported function main to return a result that can be inspected.

We could potentially use a mutable reference in JS to sidechannel the result and compare it this way for testing purposes.

@jiribenes
Copy link
Contributor

jiribenes commented Aug 21, 2024

This is truly also relevant to exit in #541. Currently it's defined there for jsNode, but I don't know what it should do on jsWeb. Perhaps we could use it for the side-channeling?

@b-studios
Copy link
Collaborator Author

There are some more tests that fail now. However, the most interesting one is the stdlib/test/test which uses the unit testing library that returns a boolean.

@jiribenes
Copy link
Contributor

jiribenes commented Aug 21, 2024

However, the most interesting [failing test] is the stdlib/test/test which uses the unit testing library that returns a boolean.

I saw this coming :^), #541 introduces def mainSuite(name: String) { body: => Unit / Test }: Unit which uses exit explicitly instead of returning a boolean which is supposed to be used exactly like def main() = mainSuite("my tests") { <tests> } :)

The problem is that it's not exactly great for how we use stdlib tests right now in the compiler — exit(1) would mean that the Scala test fails completely.

@phischu phischu merged commit 392478b into master Aug 22, 2024
2 checks passed
@phischu phischu deleted the main-unit branch August 22, 2024 13:29
@marvinborner marvinborner mentioned this pull request Sep 3, 2024
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

Successfully merging this pull request may close these issues.

3 participants