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

Speed up record inclusion check. #6289

Merged
merged 4 commits into from
Jun 7, 2023
Merged

Commits on Jun 7, 2023

  1. Speed up record inclusion check.

    Speed up record inclusion check.
    Fixes #6284
    
    Record inclusion check (between implementation and interface) is quadratic.
    
    Example:
    ```res
    module M : {
      type t<'a, 'b, 'c> = {x:list<('a, 'b)>, y:int, z:int}
    } = {
      type t<'a, 'b, 'c> = {x:list<('a, 'c)>, y:int, z:int}
    }
    ```
    
    The algorithm tries to instantiate type parameters. It only reports an error if there is an inconsistency. This requires solving type equations involving many types at once.
    
    To improve error message, the first problematic field is reported. So the type equations are checked again and again with size 1, 2, ...n where n is the number of fields. (Plus the type parameters).
    
    This is quadratic and is problematic for types of ~1K elements.
    
    This PR provides a fast path which just checks if there is an error, without blaming a specific field.
    The fast path is linear.
    Only if an error is detected, the quadratic path is take to blame precisely which field is involved.
    cristianoc committed Jun 7, 2023
    Configuration menu
    Copy the full SHA
    cda4816 View commit details
    Browse the repository at this point in the history
  2. Add text for record inclusion.

    So that there's some minimal sanity check that record type inclusion works as expected on a nontrivial case.
    cristianoc committed Jun 7, 2023
    Configuration menu
    Copy the full SHA
    4e458c0 View commit details
    Browse the repository at this point in the history
  3. Update CHANGELOG.md

    cristianoc committed Jun 7, 2023
    Configuration menu
    Copy the full SHA
    0701238 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e8361ff View commit details
    Browse the repository at this point in the history