unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.81k stars 271 forks source link

Wrongful "update" prompt / EffectConstructorHadMultipleEffects #5428

Open Baccata opened 3 weeks ago

Baccata commented 3 weeks ago

Describe and demonstrate the bug

On a codebase that compiled correctly, pulling some functions in the scratch file leads UCM to prompt me to update, without having made any modifications to the function in question. Additionally, once I do attempt to update, the compiler fails to typecheck, with some cryptic error about ability constructors having multiple effects (when in fact it's just a polymorphic ability that has a higher-kinded type parameter)

.> clone @baccata/schemas/@baccata/multiple-effects-repro
.> edit Schematic

Then save the file without touching it : UCM prompts me to update the terms, despite them having received no changes :

  Loading changes detected in ~/scratch.u.

  I found and typechecked these definitions in ~/scratch.u. If you do an `add`
  or `update`, here's how your codebase would change:

    ⍟ These names already exist. You can `update` them to your new definition:

      type schemas.Alts u a
      type schemas.Fields s a
      type schemas.Schema a
      ability schemas.abilities.AltSchematic f r u
      ability schemas.abilities.FieldSchematic f s
      ability schemas.abilities.Schematic f

After that, run the update command.

.> update 

UCM then fails typechecking :

  Loading changes detected in ~/scratch.u.

  EffectConstructorHadMultipleEffects:
    {CompileTime f1569, CompileTime f1569} (Eval (f1569 a1568))
Screenshot 2024-10-25 at 10 21 50

I can then fix the typechecking error by removing the ability ascription on the RHS of handling functions :

Screenshot 2024-10-25 at 10 22 02

Doing this everywhere until I don't get typechecking errors reverts to the original state of the codebase.

Environment (please complete the following information):