Skip to content

[#2185] Do not check for pattern anomalies on type mismatch with error recovery

Motivation and Context

This MR resolves a crash arising from a type mismatch when a matchee's type and a pattern's type are different.

Related issues

Resolves #2185 (closed).

Checklist for the LIGO Language Server

  • I checked whether I need to update the README.md file for the plugin and did so if necessary:
    • If I implemented a new LSP request, I added it to the list of supported features that may be disabled
    • If I implemented a new LSP method, I added it to the list of supported functionality
  • I checked that my changes work in Emacs, Vim, and Visual Studio Code
  • (Before merging) The commit history is squashed and prettified, and follows the Serokell commit policy, or the MR is set to squash the commits

Description

Check commit messages for details.

Component

  • compiler
  • website
  • webide
  • vscode-plugin
  • debugger

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Performance improvement (non-breaking change that improves performance)
  • None (change with no changelog)

Changelog

If typer error recovery is enabled (on for the language server), and the user writes code where there is a mismatch between a scrutinee's type and a pattern's type, it will probably lead to a crash. For example, in the following code:

type t = Unit

let Unit = ()

let () =
  match () with
  | Unit -> ()

The scrutinee (Unit : t) and the pattern (() : unit) have mismatched types (t is not the same as unit), leading to a crash.

With the changes from this changelog, this crash should no longer occur.

Checklist:

  • Changes follow the existing coding style (use dune @fmt to check).
  • Tests for the changes have been added (for bug fixes / feature).
  • Documentation has been updated.
  • Changelog description has been added (if appropriate).
  • Start titles under ## Changelog section with #### (if appropriate).
  • There is no image or uploaded file in changelog
  • Examples in changed behaviour have been added to the changelog (for breaking change / feature).
Edited by Heitor Toledo Lassarote de Paula

Merge request reports