unison
unison copied to clipboard
Ability constructors don't round-trip correctly if there's ambiguity
This code:
unique ability canvas.SpriteBuffer where
add : Sprite -> SpriteRef
drawBuffer : '('{Canvas} ())
Produces this (as expected):
.alvaro> ls canvas.SpriteBuffer
1. add (Sprite ->{SpriteBuffer} SpriteRef)
2. drawBuffer ('{SpriteBuffer} ('{Canvas} ()))
But when I view/edit it shows like this (incorrect? note the prefix in first constructor):
unique ability SpriteBuffer where
SpriteBuffer.add : Sprite ->{SpriteBuffer} SpriteRef
drawBuffer : '{SpriteBuffer} ('{Canvas} ())
Presumably because there's other terms named add
(?).
And if I save it like that, it produces this:
.alvaro> ls canvas.SpriteBuffer
1. SpriteBuffer/
2. drawBuffer ('{SpriteBuffer} ('{Canvas} ()))
The add
constructor has been placed in a new namespace :(
Good catch. I think I see the problem. It's in DeclPrinter
:
constructor (n, (_, _, t)) =
prettyPattern env ctorType name (ConstructorReference r n)
<> (fmt S.TypeAscriptionColon " :")
`P.hang` TypePrinter.pretty0 env Map.empty (-1) t
So this is just printing out the name of the constructor, when it should be deducting the type name if it exists as a prefix of that constructor's chosen name.