Skip to content

Consider getting rid of assert calls in compiler that could be user-facing #6654

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

Open
fhammerschmidt opened this issue Feb 27, 2024 · 4 comments

Comments

@fhammerschmidt
Copy link
Member

This yields cryptic errors where the user does not really know what's going on.

For instance in bsb_pkg_types.ml if the package name begins with an @ it asserts that there is a slash somewhere afterwards.
If there is no /, you get:

Fatal error: exception File “bsb_pkg_types.ml” error

Related forum post: https://forum.rescript-lang.org/t/getting-fatal-error-exception-file-bsb-pkg-types-ml-no-solution-found/5091/2

@zth
Copy link
Collaborator

zth commented Feb 27, 2024

I agree. There's a plethora of asserts in the compiler though. But fixing them continuously would indeed be great.

@cometkim
Copy link
Member

I'm facing #6539 and #6585

I think there are two cases:

  • Lazy error handling: This can be solved by simply providing an explicit error code and an appropriate description of the situation.
  • Wrong assumption: The compiler reached an invariant case never expected. Ideally, if the assumption isn't wrong, we can fix this by modifying the code, but it's not always simple. At a minimum, we should provide a message template to guide users to recognize and report this as a compiler bug. If it is absolutely necessary, there should be enough comments in the codebase to explain the assumptions that cannot be violated.

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Old issues that went stale label Feb 22, 2025
@fhammerschmidt
Copy link
Member Author

not stale

@github-actions github-actions bot removed the stale Old issues that went stale label Feb 23, 2025
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