Merge pull request #4350 from roc-lang/i4348

Use runtime representation of values when building structural eq
This commit is contained in:
Folkert de Vries 2022-10-23 01:19:17 +02:00 committed by GitHub
commit bcf2fc340d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View file

@ -147,6 +147,8 @@ fn build_eq<'a, 'ctx, 'env>(
rhs_layout: &Layout<'a>,
when_recursive: WhenRecursive<'a>,
) -> BasicValueEnum<'ctx> {
let lhs_layout = &lhs_layout.runtime_representation(env.layout_interner);
let rhs_layout = &rhs_layout.runtime_representation(env.layout_interner);
if lhs_layout != rhs_layout {
panic!(
"Equality of different layouts; did you have a type mismatch?\n{:?} == {:?}",

View file

@ -4085,3 +4085,21 @@ fn pattern_match_char() {
RocStr
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn issue_4348() {
assert_evals_to!(
indoc!(
r#"
str = "z"
(\_ ->
when str is
"z" -> "okay"
_ -> "") "FAIL"
"#
),
RocStr::from("okay"),
RocStr
);
}