unisonweb / unison

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

E261635 - `use lib.base.data.List .flatMap` crashes ucm #4536

Open johngallagher opened 10 months ago

johngallagher commented 10 months ago

What

Given I write `use lib.base.data.List .flatMap` within a function
Then I expect the code to compile or give a compilation error
But the compiler crashes

Reproduce

❌ Crashes

toFcJson : Pattern1 -> Text
toFcJson stitchPattern =
  use lib.base.data.List .flatMap
  stitchPattern
    |> flatMap
         (x -> x |> lib.base.data.List.map (a -> Json.nat a))
    |> Json.array
    |> nestWithinStitches
    |> jsonCore_1_0_3.Json.toText

✅ Compiles fine

toFcJson : Pattern1 -> Text
toFcJson stitchPattern =
  stitchPattern
    |> flatMap
         (x -> x |> lib.base.data.List.map (a -> Json.nat a))
    |> Json.array
    |> nestWithinStitches
    |> jsonCore_1_0_3.Json.toText

Error

joinDot: second name cannot be absolute.
    ( name 1 = Name Relative
        ( "List" :|
            [ "data"
            , "base"
            , "lib"
            ]
        )
    , name 2 = Name Absolute
        ( "flatMap" :| [] )
    )

  This is a Unison bug and you can report it here:

  https://github.com/unisonweb/unison/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+E261635+

  Bug reference: E261635

  If there's already an issue with this reference
🐞

joinDot: second name cannot be absolute.
    ( name 1 = Name Relative
        ( "List" :|
            [ "data"
            , "base"
            , "lib"
      🐞🐞🐞

   jjjoooii[nnn0DDD;ooo9ttt3:::;   1sssmeee]cccooonn[ddd0   mnnn
aaammm eee     ccc aaa nnn nnn ooo ttt   bb[eee0   ;aaa9bbb6sss;ooo1lllmuuu)ttteee..[

0
m
              [00;[;;90995;55;9;;1511m;mm(1((m[00m[mm 0  mnnna aamnmmeaee m  e [00;;[;990922;2;;9;1121mm;m1111m[00mm[m0  m= = =  N N=aNa mamNemea e mR ReeRe lelAalabtatsitiovivleveu
e
t
e
                              [00;[9;90696;;6;91;16m1m;([0[a0m0pmm0[00;0m;9;979;7[;1;01m1;m"m9""7[0[[mm00"mm   [|::0;90494;;4;91;14m1m;m1LmLiLisifstsltta
||m

     :   |               [   0   ;   9   3  ; [0;[090;;9[;93013;mm;11[m[[[[[9[m030 m;m 1 [[[;09;[;7909;7m71; ;m11"m"["[[9[m060m;m[[)[;009;49[9;4041;m;m1
1mmd ad dta aat taa[0[m0;0m9m[[1[;0m09;);799;71;[;m101"mmm""

0[[m00
mm

 T   h   i   s       i   s       a       U   n  i[0[[n;00 9;;b399u;33g1;; m11a,mmn,,d [0[[om00u mm   c[0[[ ;00r9;;e799p;77o1;;rm11t"mm ""i[ 0[[hm00emmr[0[[
;009;;
499;44 1;; m11mmhbtatbbspaaesss:ee[/g[[mi00tmm[ub[[;.009c;;7o99;m771/;;mu11"nmmi""[on[[mw00
emmb

 / u   n   i   s   o   n   /   i   s   s   u  e  [?u[[;t009f;;3899;=331%;;mE11,2mm%,,[[[m000 ;mm9  [;1[[;m0099;;799;71[;;m011"mmm""[%[[m0[mm[;9[[;2009;;;4199;m441;;m9113mmlilb[ii0bb[&[[mq00=mm[s%[;097[[9;0071;;;m991"72m;;"1[mm"3[m0
[[
 00 mm
  A   i   s   s   u   e   +   i   s  %  [  [[;009;3[99;0231;;;m911]3mm;3][m][[m00
m[
 0 Am  o
  p  e   n   +   E  2   [1 6 [;30956+[9;
061;;m
91)6m ;) 1[mB)[mu0
g [
 r0 em  f
  e r   [n c [;e09:5 [9;E0512;;m691,15m6;,1[5m
,[m0
 [n 0 a mnmaeI m fne a m[hee [;r09e2'[9;s021 ;;ma912l2mr;21[amd2[my0  a[=n0   m=Ni as Nms=aeu m eNeAa b mAsweboi sltAouhblt suetot
hleiu
 st  e  r
  e  f   e   r   e  n
 [e  [;
09[ap[m00m[;097[9;071;;m91"7m;"[m"[m0 [:0 |m: |  [| [;093[9;031;;m91[3m;[[m[[m00m[;093[9;031;;m91]3m;][m][m0 [ [m [;096[9;061;;m91)6m;)[m)[m0
[
 0 m
      [  [;095[9;051;;m91)5m;)[m)[m0
[

0m

 Th Ti hsi Tsih sii ssa   iaUs n Uians ioUsnno inbs uobgnu  gab nuadgn  dya onyudo  ucy aocnua  nrc earpneo prroter ptio tri tth  eihrtee r:he
e:r

e:

 ht ht tptshp:ts/t:/p/gs/i:gt/ih/tughbiu.tbch.oucmbo/.muc/nouimns/iousnnowineswboe/nbuw/neuibns/iousnno/inis/soisnsu/seiusse?ssuu?teufst8?f=u8%t=Ef%28E%=2%%
[2%[;092[9;021;;m9192m;9[m9[m0C[%0Cm% %[;092[9;021;;m912m9;319m33[m0&[q0&=mqi=s&i%qs=%[s%[;092[9;021;;m9132m;3[m3[m0A[i0AsmissuAseiu+seis+sui%es+%[s%[;092[9;021;;m9132m;3[m3[m0A[o0ApmoepnAe+onEp+2eE6n21+66E1326563+15
6+3

5+

 Bu Bg u grB eurfgee frreeernfecenerc:ee n:Ec 2eE6:21 66E1326563
156

35

 If I  ft hItefhr eetr'hese' rsae l'arsle raaedlayrd eyaa nda yni  saisnsu seiu sews iuwteih t whti httihhs i tsrh eirfsee frreeernfecenercee
nc
e

Encountered exception:
🐞

joinDot: second name cannot be absolute. (name 1 = Name Relative ("List" :| ["data","base","lib"]), name 2 = Name Absolute ("flatMap" :| []))

This is a Unison bug and you can report it here:

https://github.com/unisonweb/unison/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+E261635+

Bug reference: E261635

If there's already an issue with this reference, you can give a 👍
on the issue to let the team know you encountered it, and you can add
any additional details you know of to the issue.

CallStack (from HasCallStack):
  error, called at src/Unison/Name.hs:228:7 in unison-core1-0.0.0-46KYsVz32UPDaLJF2mZFy2:Unison.Name
  joinDot, called at src/Unison/Syntax/TermParser.hs:1119:21 in unison-parser-typechecker-0.0.0-HLhRfJvV6AvAZ9nxhsSOYZ:Unison.Syntax.TermParser
aryairani commented 10 months ago

Thanks for reporting, this is pretty bad. 😅

Maybe there's a one-line fix to make Name 2 relative.