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

The Pattern-Matching Bug: remove check_partial #13153

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

gasche
Copy link
Member

@gasche gasche commented May 7, 2024

(This PR sits on top of #13152, and is thus best review by looking at the last commit only.)

This is a non-obvious code simplification PR after #7241 is fixed. Before #7241 was reported and worked on, there already was a heuristic named check_partial to degrade pattern-matching compilation in some cases involving side-effects during matching. Now that #7241 is fixed by other changes in the pattern-matching compiler, the heuristic is not necessary anymore and complicates the code, it can be removed.

The testsuite testsuite/tests/match-side-effects/check_partial was introduced in #13121 to test various cases where the check_partial heuristic would fire. The code generated for these tests is not modified by the present PR, demonstrating that, on those tests, removing check_partial does not change the compiler behavior.

Details

The check_partial heuristics was a coarse-grained approach to degrade matching totality information in certain cases -- when clauses contain both reads of mutable fields and either guards or forcing of lazy patterns.

This heuristic is unfortunately not quite correct (it is not enough to prevent #7241), and is not sufficient conceptually for OCaml Multicore. In a Multicore world, other domains may race to update values concurrently, so we cannot assume that only a fixed set of matching constructions may result in side-effects.

The [check_partial] heuristics are a coarse-grained approach degrade
matching totality information in certain cases -- when clauses contain
both reads of mutable fields and either guards or forcing of lazy
patterns.

It is not quite correct (it is not enough to prevent ocaml#7241), and is
not sufficient conceptually for OCaml Multicore. In a Multicore world,
other domains may race to update values concurrently, so we cannot
assume that only a fixed set of matching constructions may result in
side-effects.

This heuristic is subsumed by the recent changes to:
  - make context information accurate by binding mutable fields eagerly
  - make totality information accurate by tracking the mutability of
    the current position
and can now be retired.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant