Skip to content

clone: op override (<= / =) drops the type parameters of a polymorphic operator #1047

Open

Description

@strub

Overriding a polymorphic operator during cloning fails, claiming the body has
no type parameters.

MRE

theory Thy.
  op mk (x : 'a) = (x, x).
end Thy.

clone Thy as Thy1.

clone Thy as Thy2 with
  op mk <= Thy1.mk.

Result:

operator `mk' body contains 0 type parameter instead of 1

Reproduces on main with both op mk <= Thy1.mk and op mk = Thy1.mk.

Notes

This is orthogonal to datatypes (the MRE above uses none) and to #989. It
concerns how operator overrides carry the overridden operator's type
parameters. Surfaced while investigating #989 / PR #1045.

Activity

  1. oskgo commented on Jun 15, 2026

    @oskgo
    Contributor

    There's also #1006 (comment), which might be related but uses <-.

    op gen ['a,'b]: bool = true.
    
    theory T.
    op f = gen<:unit,'a>.
    end T.
    
    op g = gen<:'a,unit>.
    
    clone T as T' with
    op f <- g.
    
  2. oskgo commented on Jun 23, 2026

    @oskgo
    Contributor

    Both cases are fixed by providing a parameter for the operator we instantiate with, even if it is abstract (op mk <= Thy1.mk<:'a> and op f <- g<:'a>)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions