Stream: beginners

Topic: Issues related to type annotations


view this post on Zulip Isaac Van Doren (Jan 01 2024 at 21:46):

I have a program where the tests pass and roc check works, but when I do roc build I get

thread 'main' panicked at 'Error in alias analysis: error in module ModName("UserApp"), function definition FuncName("\x18\x00\x00\x00\t\x00\x00\x00ib\xf5\xe0\x1a\x9f\x80\xb7"), definition of value binding ValueId(7): could not find func in module ModName("UserApp") with name FuncName("\x18\x00\x00\x00\x99\x00\x00\x00\xe2\xe7\x0b\xc3\xc7\xdc#%")', crates/compiler/gen_llvm/src/llvm/build.rs:5743:19
stack backtrace:
   0:        0x1059f7c00 - __mh_execute_header
   1:        0x104fafc2c - __mh_execute_header
   2:        0x1059f3a28 - __mh_execute_header
   3:        0x1059f7a18 - __mh_execute_header
   4:        0x1059fb754 - __mh_execute_header
   5:        0x1059fb500 - __mh_execute_header
   6:        0x1059fbd38 - __mh_execute_header
   7:        0x1059fbb24 - __mh_execute_header
   8:        0x1059fa6c0 - __mh_execute_header
   9:        0x1059fb8d8 - __mh_execute_header
  10:        0x10840d570 - __ZN4llvm15SmallVectorBaseIyE8grow_podEPvmm
  11:        0x105416270 - __mh_execute_header
  12:        0x105410b60 - __mh_execute_header
  13:        0x105166b34 - __mh_execute_header
  14:        0x10516a564 - __mh_execute_header
  15:        0x105168fd0 - __mh_execute_header
  16:        0x10522eabc - __mh_execute_header
  17:        0x10513d764 - __mh_execute_header
  18:        0x1051322b4 - __mh_execute_header
  19:        0x1051322d8 - __mh_execute_header
  20:        0x1059ec880 - __mh_execute_header
  21:        0x10513f404 - __mh_execute_header

I thought removing some type annotations might fix this, but unfortunately, when I do that, check and build both hang.

Any suggestions?

view this post on Zulip Isaac Van Doren (Jan 01 2024 at 21:47):

If I comment out this line alone that is enough to get roc check/build to hang

view this post on Zulip Luke Boswell (Jan 01 2024 at 22:24):

Every time I have seen the Error in alias analysis part I think it has been an issue related to LambdaSets. I'm not sure if that is what is going on here. In my experience there is usually another way to structure the program to achieve the same outcome without this issue.

view this post on Zulip Isaac Van Doren (Jan 02 2024 at 02:46):

Maybe this is worth putting in a different thread, but there's another bug that is occurring in the function whose type signature is causing the issue above (on the previous commit which does build).

This is the smallest reproduction I could come up with. The expect sometimes succeeds and sometimes fails with result being [Number 4], or a value similar to [Number 4966104036].

Term : [
    Number I64,
    Quotation (List Term),
]

stepBuiltin : List Term -> List Term
stepBuiltin = \stack ->
    when stack is
        [.., Number x, Number y] ->
            # dbg stack
            [Number (x + y)]

        _ -> []

expect
    result = stepBuiltin [Number 4, Number 8]
    result == [Number 12]

If you uncomment the dbg in that position specifically, it makes the expect pass every time.

I assume this is related to recursive types and lambda sets, so I know there may not be an easy solution, but perhaps the example is helpful.


Last updated: Jul 06 2025 at 12:14 UTC