-
Notifications
You must be signed in to change notification settings - Fork 80
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
Fix confusing disambiguation errors appearing instead of type errors #768
Conversation
When a non-delayed error happens after delayed errors, these should take precedence and be raised rather than ignored. Indeed, it's often a consequence of delayed errors. This happened in the disambiguation phase where a type inconsistency would be skipped, leading to a failure to disambiguate, and only the latter was printed resulting in a puzzling error.
let result = | ||
match f () with | ||
| r -> fun () -> r | ||
| exception (CompilerError _ as e) -> | ||
let bt = Printexc.get_raw_backtrace () in | ||
fun () -> Printexc.raise_with_backtrace e bt | ||
| exception e -> raise e | ||
in | ||
match global_errors.errors with | ||
| None -> error ~internal:true "intertwined delayed error scope" | ||
| Some [] -> | ||
global_errors.errors <- None; | ||
result () | ||
| Some [err] -> | ||
global_errors.errors <- None; | ||
raise (CompilerError err) | ||
| Some errs -> | ||
global_errors.errors <- None; | ||
raise e | ||
raise (CompilerErrors (List.rev errs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could use a little comment to understand what's going on :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, sorry about that..
@vincent-botbol haha don't worry you certainly have as much on my account ;) |
Closes #749 ;
the PR also has a patch that greatly improves real disambiguation errors when they happen.
The issue was actually with the way we attempt to gather multiple typing errors: this can get us in an inconsistent state after the first error, and any non-delayed exception raised at that point (including
internal inconsistency
compiler errors) would break out... and hide all delayed exceptions.This is visible in test
array/bad/type_error_in_filter.catala_en
which would raise aCannot resolve typing
error because assumptions of the typer are no longer guaranteed.The behaviour implemented here is to print the errors that have been delayed, and actually hide the non-delayed error instead (it seems safer to assume, in general, that it is a consequence of an inconsistent state, rather than the opposite. We could put it back when in debug mode if we ever find cases where it would have been useful).