You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
clone: datatype-type override crashes (CoreIncompatible) when an operator matches on a constructor #1046
When a datatype's type is overridden during cloning, an operator whose body pattern-matches on the datatype's constructors (i.e. compiles to OP_Fix)
triggers an anomaly during the operator-compatibility check.
MRE
theory Thy.
type ATy = [ CB of int ].
op getit (x : ATy) = with x = CB n => n.
end Thy.
clone Thy as Thy1.
clone Thy as Thy2 with
type ATy = Thy1.ATy,
op getit <= Thy1.getit.
Result:
anomaly: EcLib.EcTheoryReplay.CoreIncompatible
Reproduces on main in both override modes (type ATy = ... and type ATy <- ...).
Cause
Same root cause as #989: when a datatype's type is overridden, the source
datatype's constructors are not re-created in the clone, so references to them
must be redirected to the target datatype's constructors. EcTheoryReplay.replay_tyd performs this redirect only for OP_Constr
references, not for OP_Fix match bodies.
PR #1045 (fixing #989) extends the redirect to plain constructor references in
both override modes, but does not widen it to OP_Fix.
I'd like to take this one. I have a fix working locally: the redirect added in #1045 registers the
target constructors through EcSubst.add_opdef, which only rewrites constructors where they appear
as operator expressions. A match body stores each branch's constructor as a bare path in opb_ctor, and that goes through the path map instead, so the branch constructors kept pointing at
the source datatype and the compatibility check compared unequal paths. Recording the redirect in a
small dedicated map that is consulted where opb_ctor is substituted fixes both override modes; it
has to stay out of the general path map, since that one is applied recursively through path
qualifiers and constructors share a namespace with sub-theories and types. I'll open a PR with a
regression test shortly.
Activity
MavenRain commentedon Jul 31, 2026
I'd like to take this one. I have a fix working locally: the redirect added in #1045 registers the
target constructors through
EcSubst.add_opdef, which only rewrites constructors where they appearas operator expressions. A match body stores each branch's constructor as a bare path in
opb_ctor, and that goes through the path map instead, so the branch constructors kept pointing atthe source datatype and the compatibility check compared unequal paths. Recording the redirect in a
small dedicated map that is consulted where
opb_ctoris substituted fixes both override modes; ithas to stay out of the general path map, since that one is applied recursively through path
qualifiers and constructors share a namespace with sub-theories and types. I'll open a PR with a
regression test shortly.