mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-09 02:54:49 +00:00
parent
1a9a0d5d01
commit
eebe5234f6
2 changed files with 44 additions and 1 deletions
|
|
@ -4874,7 +4874,10 @@ pub fn with_hole<'a>(
|
||||||
stmt =
|
stmt =
|
||||||
Stmt::Let(*symbol, access_expr, *field_layout, arena.alloc(stmt));
|
Stmt::Let(*symbol, access_expr, *field_layout, arena.alloc(stmt));
|
||||||
|
|
||||||
if record_needs_specialization {
|
// If the records needs specialization or it's a thunk, we need to
|
||||||
|
// create the specialized definition or force the thunk, respectively.
|
||||||
|
// Both cases are handled below.
|
||||||
|
if record_needs_specialization || procs.is_module_thunk(structure) {
|
||||||
stmt = specialize_symbol(
|
stmt = specialize_symbol(
|
||||||
env,
|
env,
|
||||||
procs,
|
procs,
|
||||||
|
|
|
||||||
|
|
@ -1044,3 +1044,43 @@ fn generalized_accessor() {
|
||||||
RocStr
|
RocStr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
|
fn update_record_that_is_a_thunk() {
|
||||||
|
assert_evals_to!(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
app "test" provides [main] to "./platform"
|
||||||
|
|
||||||
|
main = Num.toStr fromOriginal.birds
|
||||||
|
|
||||||
|
original = { birds: 5, iguanas: 7, zebras: 2, goats: 1 }
|
||||||
|
|
||||||
|
fromOriginal = { original & birds: 4, iguanas: 3 }
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
RocStr::from("4"),
|
||||||
|
RocStr
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
|
fn update_record_that_is_a_thunk_single_field() {
|
||||||
|
assert_evals_to!(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
app "test" provides [main] to "./platform"
|
||||||
|
|
||||||
|
main = Num.toStr fromOriginal.birds
|
||||||
|
|
||||||
|
original = { birds: 5 }
|
||||||
|
|
||||||
|
fromOriginal = { original & birds: 4 }
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
RocStr::from("4"),
|
||||||
|
RocStr
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue