Skip to content

Fix spurious invariant propagation for measures on type synonyms - #2660

Merged
facundominguez merged 1 commit into
developfrom
fd/poly-measures
Apr 30, 2026
Merged

facundominguez merged 1 commit into
developfrom
fd/poly-measures

Conversation

@facundominguez

Copy link
Copy Markdown
Collaborator

Replace tcUnifyTy with tcMatchTy in goodInvs to prevent measure invariants from being applied to binders whose type arguments are too general. Previously, a measure on [Diff [a]] (via a type synonym Hunk a) would have its Nat invariant (ms v >= 0) spuriously attached to plain [a] binders, causing elaboration failures.

The fix uses one-directional matching so that an invariant's type args must be matchable from the target type args (i.e., the target must be an instance of the invariant's expected type). This prevents a type variable in the target from absorbing a structured invariant arg.

Replace tcUnifyTy with tcMatchTy in goodInvs to prevent measure
invariants from being applied to binders whose type arguments are
too general. Previously, a measure on [Diff [a]] (via a type synonym
Hunk a) would have its Nat invariant (ms v >= 0) spuriously attached
to plain [a] binders, causing elaboration failures.

The fix uses one-directional matching so that an invariant's type args
must be matchable *from* the target type args (i.e., the target must be
an instance of the invariant's expected type). This prevents a type
variable in the target from absorbing a structured invariant arg.

@ninioArtillero ninioArtillero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for addressing this!

@facundominguez
facundominguez merged commit dbe903f into develop Apr 30, 2026
6 checks passed
@facundominguez
facundominguez deleted the fd/poly-measures branch April 30, 2026 21:30
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.

2 participants