Handle record updates of imported module thunks

Closes #5131
This commit is contained in:
Ayaz Hafiz 2023-04-12 11:39:14 -05:00
parent bbd09fed3c
commit 65911f88b1
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 17 additions and 8 deletions

View file

@ -5049,9 +5049,12 @@ pub fn with_hole<'a>(
);
}
CopyExisting(index) => {
let record_needs_specialization =
procs.ability_member_aliases.get(structure).is_some();
let specialized_structure_sym = if record_needs_specialization {
let structure_needs_specialization =
procs.ability_member_aliases.get(structure).is_some()
|| procs.is_module_thunk(structure)
|| procs.is_imported_module_thunk(structure);
let specialized_structure_sym = if structure_needs_specialization {
// We need to specialize the record now; create a new one for it.
// TODO: reuse this symbol for all updates
env.unique_symbol()
@ -5068,10 +5071,7 @@ pub fn with_hole<'a>(
stmt =
Stmt::Let(*symbol, access_expr, *field_layout, arena.alloc(stmt));
// 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) {
if structure_needs_specialization {
stmt = specialize_symbol(
env,
procs,

View file

@ -16,8 +16,17 @@ main =
{ defaultRequest & url: "http://www.example.com" }
# -emit:mono
procedure Dep.0 ():
let Dep.2 : Str = "";
let Dep.3 : Str = "";
let Dep.1 : {Str, Str} = Struct {Dep.2, Dep.3};
ret Dep.1;
procedure Test.0 ():
let Test.3 : Str = "http://www.example.com";
let Test.2 : Str = StructAtIndex 0 Dep.0;
let Test.4 : {Str, Str} = CallByName Dep.0;
let Test.2 : Str = StructAtIndex 0 Test.4;
inc Test.2;
dec Test.4;
let Test.1 : {Str, Str} = Struct {Test.2, Test.3};
ret Test.1;