roc icon indicating copy to clipboard operation
roc copied to clipboard

map in map panics compiler

Open rudolfvesely opened this issue 1 year ago • 5 comments

Hi folks,

Please try this one with the most current ROC (build from Nix flake):

combine = \first, second -> List.joinMap first (\x -> List.map second (\y -> (x, y)))

# OK:
expect
    x = combine [1] [2, 3]
    x == [(1, 2), (1, 3)]

# OK:
expect
    x = combine ["a", "b"] [1, 2]
    x == [("a", 1), ("a", 2), ("b", 1), ("b", 2)]

# OK:
expect
    x = combine [1, 2] []
    x == []

# this one:
# expect
#     x = combine [] [1, 2]
#     x == []
# fails:
#     thread 'main' panicked at crates/compiler/gen_llvm/src/llvm/build.rs:3391:30:
#     called `Result::unwrap()` on an `Err` value: AlignmentError("The src_align_bytes argument to build_memcpy was not a power of 2.")
#     note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

rudolfvesely avatar Aug 22 '24 12:08 rudolfvesely

Thanks for alerting us @rudolfvesely!

Looks like this issue was caused by c5a74bdc1254152f5faf9bd12ca3d10f6bf2ca8c

  • [ ] We should add a test for this after this is fixed.

I'll do a bit of investigating right now

Anton-4 avatar Aug 23 '24 10:08 Anton-4

The alignment and size here are 0, that should not happen :p

This could be because of the empty list

Anton-4 avatar Aug 23 '24 10:08 Anton-4

Can you recommend next steps @bhansconnect ?

Anton-4 avatar Aug 23 '24 11:08 Anton-4

This was fixed in https://github.com/roc-lang/roc/pull/7024 :tada:

I'm just going to leave this open until I add this to the tests

Anton-4 avatar Aug 26 '24 09:08 Anton-4

Thank you @Anton-4 . I've just updated Roc and can confirm the issue was fixed.

rudolfvesely avatar Aug 27 '24 04:08 rudolfvesely

No longer reproduces

JRI98 avatar Nov 24 '24 12:11 JRI98

We need to add a test in cli_tests for the original issue so it never happens again

Anton-4 avatar Nov 25 '24 13:11 Anton-4