Skip to content

Commit

Permalink
Fix #2317: Look at the type note of the object field (#2318)
Browse files Browse the repository at this point in the history
when creating an object, to determine the mutability of the field (which affects how it gets compiled), do _not_ look at the type note of the record (which may lack some fields due to subtyping), but look at the type note of the field itself.

Fixes #2317
  • Loading branch information
nomeata authored Feb 8, 2021
1 parent 1aa1781 commit 59a0d2b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/codegen/compile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7379,7 +7379,7 @@ and compile_exp (env : E.t) ae exp =
SR.Vanilla,
let fs' = fs |> List.map
(fun (f : Ir.field) -> (f.it.name, fun () ->
if Object.is_mut_field env exp.note.Note.typ f.it.name
if Type.is_mut f.note
then Var.get_aliased_box env ae f.it.var
else Var.get_val_vanilla env ae f.it.var)) in
Object.lit_raw env fs'
Expand Down
5 changes: 5 additions & 0 deletions test/run-drun/issue2317.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
actor {
public func baz(b : Bool) : () {
ignore({b = b} : {})
};
}
2 changes: 2 additions & 0 deletions test/run-drun/ok/issue2317.drun-run.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101
ingress Completed: Reply: 0x4449444c0000
4 changes: 4 additions & 0 deletions test/run-drun/ok/issue2317.ic-ref-run.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
→ update create_canister()
← replied: (record {hymijyo = service "cvccv-qqaaq-aaaaa-aaaaa-c"})
→ update install_code(record {arg = blob ""; kca_xin = blob "\00asm\01\00\00\00\0…
← replied: ()

0 comments on commit 59a0d2b

Please sign in to comment.