Consider getting rid of `assert` calls in compiler that could be user-facing
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
I agree. There's a plethora of asserts in the compiler though. But fixing them continuously would indeed be great.
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.
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.
not stale