ta0kira / zeolite

Zeolite is a statically-typed, general-purpose programming language.
Apache License 2.0
18 stars 0 forks source link

Make `withContextM` usage consistent so that warnings don't look like errors. #102

Closed ta0kira closed 3 years ago

ta0kira commented 3 years ago

The code currently uses withContextM (previously reviseErrorM) in several different ways:

  1. To add a parent message indicating why nested operations happened, e.g., checking args passed to a function.
  2. To direct the user to where to look for more information in the code, e.g., the name and line number of a testcase.
  3. To provide the "real" error message when no alternatives were found, i.e., a failed mergeAnyM or collectFirstM.

Since CompileInfoT applies the context to both warnings and errors, using withContextM for error messages makes nested warnings appear to be errors.

For example, compileWarningM "Warning" <?? "Error!" results in a success with a warning what includes "Error!" as its context.

So, it might make sense to add a second function to CompileErrorM that behaves like reviseErrorM used to before warnings could be nested, e.g., summarizeErrorM.