CatalaLang / catala

Programming language for literate programming law specification
https://catala-lang.org
Apache License 2.0
1.96k stars 79 forks source link

Printf multiple errors before exiting #250

Closed denismerigoux closed 3 weeks ago

denismerigoux commented 2 years ago

Currently, the Catala compiler exits at the first error it encounters. It would be nice to only exit when the errors it has found forbid it to continue processing, so that it displays multiple related error messages in the same run.

For that, every AST should be augmented with an Error case produced when an error message is raised. The compiler could then continue its operations until it actually needs to do something with the location of the AST where Error is, in which case it would exit.

pierregoutagny commented 6 months ago

I think it would be quite useful to me as well to have an Error case in the AST, because it would allow me to continue other branches of evaluation after an error is found. I have been considering using OCaml's Result module to make the concolic evaluator return a ((dcalc,'m) gexpr, type_for_errors) result, but an AST case would probably be better. How much effort do you think it would need to at least add the Error AST case (even if it's underused at first)?

denismerigoux commented 6 months ago

I guess one solid (if not two) days of refactoring following the OCaml compiler errors...

denismerigoux commented 3 weeks ago

Vincent has implemented this for parsing and typechecking errors only. This issue is closed in favor of a new one that should generalize this mechanism.