unison icon indicating copy to clipboard operation
unison copied to clipboard

`core.Json.tests.genText` doesn't round-trip typecheck

Open aryairani opened this issue 1 month ago • 1 comments

Describe and demonstrate the bug

> clone @unison/json
> edit core.Json.tests.genText

The existing definition doesn't typecheck:

core.Json.tests.genText : '{Random} Text
core.Json.tests.genText =
  do
    ch =
      Random.weighted
        [ (20, ascii.lower)
        , (5, do Random.oneOf [?\s, ?\n, ?\r, ?\t])
        , (20, ascii.upper)
        , (20, char.digit)
        , (2, unicode)
        ]
    ofChars ch (Random.natIn 0 15)

This annotated version is ok:

core.Json.tests.genText : '{Random} Text
core.Json.tests.genText =
  do
    ch =
      Random.weighted
        ([ (20, ascii.lower)
        , (5, do Random.oneOf [?\s, ?\n, ?\r, ?\t])
        , (20, ascii.upper)
        , (20, char.digit)
        , (2, unicode)
        ] : [(Nat, '{Random} Char)])
    ofChars ch (Random.natIn 0 15)

Having trouble getting this example to reproduce in the transcript runner though.

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • ucm 2447f52 and 1.0.0

Additional context I think this is a known issue

aryairani avatar Dec 04 '25 17:12 aryairani

I don't think that this is a roundtrip issue in the traditional since. https://github.com/unisonweb/unison/pull/5960 introduced some type checker changes that made a lot of definitions no longer type check. If you save this with the type annotation then it roundtrips, right?

But I do think that these recently introduced type check failures involving abilities are pretty bewildering and worry that they will trip people up.

ceedubs avatar Dec 04 '25 18:12 ceedubs