Skip to content

Commit

Permalink
fixes ldelema instruction missing target type and updates expecteatio…
Browse files Browse the repository at this point in the history
…n in tests accordingly

this issue was discovered while working on #243
  • Loading branch information
adrianoc committed Aug 5, 2023
1 parent a74893e commit e11307c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void ArrayElementAssignment(string arrayVariable)
result.GeneratedCode.ReadToEnd(), Does.Match(
@"il_M_4.Emit\(OpCodes.(?:Ldarg_1|Ldfld, fld_f_2)\);
il_M_4.Emit\(OpCodes.Ldc_I4, 1\);
il_M_4.Emit\(OpCodes.Ldelema\);
il_M_4.Emit\(OpCodes.Ldelema, st_myStruct_0\);
il_M_4.Emit\(OpCodes.Initobj, st_myStruct_0\);"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override void VisitElementAccessExpression(ElementAccessExpressionSyntax

//...since we have an `assignment` to an array element which is of type
//struct, we need to load the element address instead.
Context.EmitCilInstruction(ilVar, OpCodes.Ldelema);
Context.EmitCilInstruction(ilVar, OpCodes.Ldelema, resolvedInstantiatedType);
Context.EmitCilInstruction(ilVar, OpCodes.Initobj, resolvedInstantiatedType);
}

Expand Down

0 comments on commit e11307c

Please sign in to comment.