mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Copy list values from the correct offset when reporting expects
Co-authored-by: Folkert de Vries <folkert@folkertdev.nl>
This commit is contained in:
parent
166be98ac8
commit
c4a3a8bd31
2 changed files with 49 additions and 2 deletions
|
@ -935,7 +935,8 @@ fn build_clone_builtin<'a, 'ctx, 'env>(
|
|||
|
||||
bd.build_int_add(offset, elements_width, "new_offset")
|
||||
} else {
|
||||
let elements_start_offset = offset;
|
||||
// We cloned the elements into the extra_offset address.
|
||||
let elements_start_offset = cursors.extra_offset.into();
|
||||
|
||||
let element_type = basic_type_from_layout(env, elem);
|
||||
let elements = bd.build_pointer_cast(
|
||||
|
|
|
@ -339,7 +339,7 @@ mod test {
|
|||
When it failed, these variables had these values:
|
||||
|
||||
a : List (List Str)
|
||||
a = [[""], []]
|
||||
a = [["foo"], []]
|
||||
|
||||
b : List (List Str)
|
||||
b = [["a string so long that it cannot be short", "bar"]]
|
||||
|
@ -847,4 +847,50 @@ mod test {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn big_recursive_tag_copied_back() {
|
||||
run_expect_test(
|
||||
indoc!(
|
||||
r#"
|
||||
interface A exposes [] imports []
|
||||
|
||||
NonEmpty := [
|
||||
First Str U8,
|
||||
Next (List { item: Str, rest: NonEmpty }),
|
||||
]
|
||||
|
||||
expect
|
||||
nonEmpty =
|
||||
a = "abcdefgh"
|
||||
b = @NonEmpty (First "ijkl" 67u8)
|
||||
c = Next [{ item: a, rest: b }]
|
||||
@NonEmpty c
|
||||
|
||||
when nonEmpty is
|
||||
_ -> False
|
||||
"#
|
||||
),
|
||||
indoc!(
|
||||
r#"
|
||||
This expectation failed:
|
||||
|
||||
8│> expect
|
||||
9│> nonEmpty =
|
||||
10│> a = "abcdefgh"
|
||||
11│> b = @NonEmpty (First "ijkl" 67u8)
|
||||
12│> c = Next [{ item: a, rest: b }]
|
||||
13│> @NonEmpty c
|
||||
14│>
|
||||
15│> when nonEmpty is
|
||||
16│> _ -> False
|
||||
|
||||
When it failed, these variables had these values:
|
||||
|
||||
nonEmpty : NonEmpty
|
||||
nonEmpty = @NonEmpty (Next [{ item: "abcdefgh", rest: @NonEmpty (First "ijkl" 67) }])
|
||||
"#
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue