This commit is contained in:
Ivan Bondarev 2021-04-04 11:04:27 +02:00
parent 772489a15e
commit 27dafcbdfd
2 changed files with 29 additions and 0 deletions

24
TestSuite/with3.pas Normal file
View file

@ -0,0 +1,24 @@
type
node = class
i: integer;
function f1: node := new node;
end;
begin
var n1 := new node;
var n2: node;
with n1 do
begin
// Обязательно вложенный with
n2 := f1;
with n2 do
begin
i := 2;
end;
// Обязательно вызвать метод после вложенного with
f1;
i := 1;
end;
assert(n1.i = 1);
assert(n2.i = 2);
end.

View file

@ -9022,6 +9022,11 @@ namespace PascalABCCompiler.TreeConverter
foreach (expression_node vr in VarRefs)
{
context.WithVariables.Remove(vr.type.Scope);
if (!context.WithVariables.ContainsKey(vr.type.Scope) && OldWithVariables.ContainsKey(vr.type.Scope))
{
context.WithVariables.Add(vr.type.Scope, OldWithVariables[vr.type.Scope]);
OldWithVariables.Remove(vr.type.Scope);
}
type_node tn = vr.type.base_type;
while (tn != null)
{