map in map panics compiler
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
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
The alignment and size here are 0, that should not happen :p
This could be because of the empty list
Can you recommend next steps @bhansconnect ?
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
Thank you @Anton-4 . I've just updated Roc and can confirm the issue was fixed.
No longer reproduces
We need to add a test in cli_tests for the original issue so it never happens again