Skip to content

Add contextual rewrite-pattern selection#955

Merged
strub merged 2 commits intomainfrom
rw-pattern-ctxt
Apr 13, 2026
Merged

Add contextual rewrite-pattern selection#955
strub merged 2 commits intomainfrom
rw-pattern-ctxt

Conversation

@strub
Copy link
Copy Markdown
Member

@strub strub commented Mar 26, 2026

Allow rewrite patterns to designate a subterm inside a
larger context with the [x in pattern] syntax.

This lets rewrite target exactly the occurrence named by
the surrounding context, and adds regression coverage for
that form.

The context variable must appear exactly once in the pattern
(linearity check). Delta expansion and conversion are disabled
during contextual pattern matching to ensure position computation
remains sound.

@strub strub self-assigned this Mar 26, 2026
@strub strub force-pushed the rw-pattern-ctxt branch 6 times, most recently from c4fd44b to 7c7d74a Compare April 13, 2026 11:33
@Gustavo2622 Gustavo2622 self-requested a review April 13, 2026 11:38
strub added 2 commits April 13, 2026 18:02
Allow rewrite patterns to designate a subterm inside a
larger context with the [x in pattern] syntax.

This lets rewrite target exactly the occurrence named by
the surrounding context, and adds regression coverage for
that form.

The context variable must appear exactly once in the pattern
(linearity check). Delta expansion and conversion are disabled
during contextual pattern matching to ensure position computation
remains sound.
Split the `Some (prw, subl)` match arm into two separate
cases — plain r-pattern and contextual r-pattern — so that
the strict no-conv/no-delta matching constraint is structurally
scoped to the contextual branch. The permissive `modes` from
the outer scope is no longer reachable from the contextual code.
@strub strub force-pushed the rw-pattern-ctxt branch from e1d30cf to ef07798 Compare April 13, 2026 16:02
@strub strub added this pull request to the merge queue Apr 13, 2026
Merged via the queue into main with commit 29e0baa Apr 13, 2026
17 of 18 checks passed
@strub strub deleted the rw-pattern-ctxt branch April 13, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants