OCamlPro / niagara-lang

Compiler for the Niagara language
GNU Affero General Public License v3.0
3 stars 6 forks source link

Use symbolic error representations #16

Open Keryan-dev opened 10 months ago

Keryan-dev commented 10 months ago

Essentially remove failures on error from everything but the executable.

The main culprit is Errors.raise_error

Ninjapouet commented 8 months ago

What's the objective beyond that rewriting ?

Keryan-dev commented 8 months ago

To allow a more refine handling of failure. For better error messages, better diagnosis for the source of error (e.g. having to point out several code locations to explain an issue), etc. Also not having to rely on a catch-all when using the library.

Note that the logs mechanism already addresses part of it.

Ninjapouet commented 8 months ago

That's the point of my question : there is globally 3 strategies for error reporting with traces :

Symbolic errors (in the general OCaml sense) are mostly used for the monadic solution but as the compiler is not written in a monadic style, it would require a lot of rewriting which is usually a bad idea. We can use an exception system but the current log system allows to specify rust-like errors which seems sufficient in practice if we don't specially need a fullstack trace (and in this case, we can combine with it the exception stack).

Keryan-dev commented 8 months ago

I think the log system is fine as an endpoint. Some pieces of the compiler with require some work to have more precise failure reporting before raising actual errors to the user. This could be achieved through richer return types or exceptions, and this is what I meant by symbolic, sorry for the confusion.

We will need a proper way to carry error/diagnostic information internally, as I feel logging is more fitted to the compiler interface.