Skip to content
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

Refactoring the typechecking error handling #85

Merged
merged 25 commits into from
Dec 3, 2018

Commits on Nov 28, 2018

  1. [wip] Refactoring the typechecking error handling

    I have a strong urge to refactor the error accumulation; this
    `recover_with` and `return_with` isn’t really pretty, adds quite useless
    noise to the code, and prevents easy use of existing combinators like
    `List.iter`.
    
    So I propose this:
    * We collect error messages and warnings in a mutable reference (a list
      or rope) that we just pass down as argument (inside `env`). This is
      used to collect errors (and warnings), but not for control flow.
      (This simulates the writer monad, without the syntactic overhead).
    * The exception no longer carries an argument. This is raised when we
      cannot continue due to an error.
      (This simulates the Maybe monad for computations-that-may-fail.)
    * There is a `recover_with` function that catches the Error, and continues
      with a useful default.
    * At the end, we report all errors and warnings in the mutable ref. And
      if there are any errors, we abort compilation.
      See `recover_and_report`
    
    Now any use of `error` does not abort futher processing, only
    `fatal_error` does.
    
    The code in `pipeline.ml` is maybe not the prettiest yet, but lets first
    see if this approach actually works inside `typing.ml`.
    nomeata committed Nov 28, 2018
    Configuration menu
    Copy the full SHA
    5b47258 View commit details
    Browse the repository at this point in the history
  2. Ha, values are not functions

    nomeata committed Nov 28, 2018
    Configuration menu
    Copy the full SHA
    b67b04a View commit details
    Browse the repository at this point in the history
  3. Report warnings and errors differently

    and more closely match what we had before
    nomeata committed Nov 28, 2018
    Configuration menu
    Copy the full SHA
    58a700b View commit details
    Browse the repository at this point in the history
  4. Make duplicate field error fatal

    the function gather_field_exp is run thrice; not a good place for a
    non-fatal error.
    
    This could be refined to make sure the check happens only once, either
    by passing down a flag to exactly one invocation of `gather_field_exp`,
    or moving the check to a separate, explicitly used function alltogether.
    nomeata committed Nov 28, 2018
    Configuration menu
    Copy the full SHA
    bc9dbf5 View commit details
    Browse the repository at this point in the history
  5. Update js_main.ml

    this means that now also warnings will be reported nicely! Will
    hopefully make @paulyoung even happier.
    nomeata committed Nov 28, 2018
    1 Configuration menu
    Copy the full SHA
    937f6c1 View commit details
    Browse the repository at this point in the history
  6. In gather_pat, do not check for duplicates

    as these are checked elsewhere. Improves the error message.
    nomeata committed Nov 28, 2018
    Configuration menu
    Copy the full SHA
    75a906e View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    e0cf6c3 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    b777064 View commit details
    Browse the repository at this point in the history

Commits on Nov 29, 2018

  1. Configuration menu
    Copy the full SHA
    fd4e3c4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    972c02c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0e9af01 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    c9b2e0c View commit details
    Browse the repository at this point in the history
  5. Move messages into the branches of result

    not sure if it really is better, but not worth arguing about.
    nomeata committed Nov 29, 2018
    Configuration menu
    Copy the full SHA
    6ea19f3 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    36b6f6c View commit details
    Browse the repository at this point in the history
  7. More non-recoverable errors in the type checker

    in particular, everything around sharable functions,  and duplicate
    bindings.
    nomeata committed Nov 29, 2018
    Configuration menu
    Copy the full SHA
    6368ceb View commit details
    Browse the repository at this point in the history
  8. Merge remote-tracking branch 'origin' into typecheck-error-refactor

    this pulls in #88 and addresses the nit that `typing.mli` should not
    mention the `errs` field.
    nomeata committed Nov 29, 2018
    Configuration menu
    Copy the full SHA
    5908462 View commit details
    Browse the repository at this point in the history
  9. Typing.env: s/errs/msgs/

    nomeata committed Nov 29, 2018
    Configuration menu
    Copy the full SHA
    e1e2059 View commit details
    Browse the repository at this point in the history

Commits on Dec 3, 2018

  1. Configuration menu
    Copy the full SHA
    86a1242 View commit details
    Browse the repository at this point in the history
  2. Get rid of 'let abort = _

    nomeata committed Dec 3, 2018
    Configuration menu
    Copy the full SHA
    5fa56ac View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    bf1ee05 View commit details
    Browse the repository at this point in the history
  4. Also update js_main.ml

    nomeata committed Dec 3, 2018
    Configuration menu
    Copy the full SHA
    a9ff72c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    f91fb4e View commit details
    Browse the repository at this point in the history
  6. Update test output

    hopefully we can resolve #92 soon, stack traces in the test output are a
    PITA (I should probably add a post-proccessing filter that normalizes
    the output a bit).
    nomeata committed Dec 3, 2018
    Configuration menu
    Copy the full SHA
    61e0e5e View commit details
    Browse the repository at this point in the history
  7. s/Abort/Recover

    nomeata committed Dec 3, 2018
    Configuration menu
    Copy the full SHA
    5c2f0d8 View commit details
    Browse the repository at this point in the history
  8. Abstract common patterns between check_prog and infer_prog

    the definiton of messages_result will eventually go into a separate
    module
    nomeata committed Dec 3, 2018
    1 Configuration menu
    Copy the full SHA
    b0d6332 View commit details
    Browse the repository at this point in the history