@@ -533,7 +533,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor
533
533
const inLoopSave = sc.inLoop;
534
534
sc.inLoop = true ;
535
535
if (ds._body)
536
- ds._body = ds._body.semanticScope(sc, ds, ds);
536
+ ds._body = ds._body.semanticScope(sc, ds, ds, null );
537
537
sc.inLoop = inLoopSave;
538
538
539
539
if (ds.condition.op == TOK .dotIdentifier)
@@ -2342,7 +2342,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor
2342
2342
CtorFlow ctorflow_then = sc.ctorflow; // move flow results
2343
2343
sc.ctorflow = ctorflow_root; // reset flow analysis back to root
2344
2344
if (ifs.elsebody)
2345
- ifs.elsebody = ifs.elsebody.semanticScope(sc, null , null );
2345
+ ifs.elsebody = ifs.elsebody.semanticScope(sc, null , null , null );
2346
2346
2347
2347
// Merge 'then' results into 'else' results
2348
2348
sc.merge(ifs.loc, ctorflow_then);
@@ -3922,13 +3922,9 @@ private extern (C++) final class StatementSemanticVisitor : Visitor
3922
3922
enum FLAGcpp = 1 ;
3923
3923
enum FLAGd = 2 ;
3924
3924
3925
- tcs.tryBody = sc.tryBody;
3926
-
3927
- scope sc2 = sc.push();
3928
- sc2.tryBody = tcs;
3929
- tcs._body = tcs._body.semanticScope(sc2, null , null );
3925
+ tcs.tryBody = sc.tryBody; // chain on the in-flight tryBody
3926
+ tcs._body = tcs._body.semanticScope(sc, null , null , tcs);
3930
3927
assert (tcs._body);
3931
- sc2.pop();
3932
3928
3933
3929
/* Even if body is empty, still do semantic analysis on catches
3934
3930
*/
@@ -4009,12 +4005,8 @@ private extern (C++) final class StatementSemanticVisitor : Visitor
4009
4005
override void visit (TryFinallyStatement tfs)
4010
4006
{
4011
4007
// printf("TryFinallyStatement::semantic()\n");
4012
- tfs.tryBody = sc.tryBody;
4013
-
4014
- auto sc2 = sc.push();
4015
- sc2.tryBody = tfs;
4016
- tfs._body = tfs._body.statementSemantic(sc2);
4017
- sc2.pop();
4008
+ tfs.tryBody = sc.tryBody; // chain on in-flight tryBody
4009
+ tfs._body = tfs._body.semanticScope(sc, null , null , tfs);
4018
4010
4019
4011
sc = sc.push();
4020
4012
sc.tf = tfs;
@@ -4445,7 +4437,7 @@ Statement semanticNoScope(Statement s, Scope* sc)
4445
4437
}
4446
4438
4447
4439
// Same as semanticNoScope(), but do create a new scope
4448
- Statement semanticScope (Statement s, Scope* sc, Statement sbreak, Statement scontinue)
4440
+ private Statement semanticScope (Statement s, Scope* sc, Statement sbreak, Statement scontinue, Statement tryBody )
4449
4441
{
4450
4442
auto sym = new ScopeDsymbol();
4451
4443
sym.parent = sc.scopesym;
@@ -4454,6 +4446,8 @@ Statement semanticScope(Statement s, Scope* sc, Statement sbreak, Statement scon
4454
4446
scd.sbreak = sbreak;
4455
4447
if (scontinue)
4456
4448
scd.scontinue = scontinue;
4449
+ if (tryBody)
4450
+ scd.tryBody = tryBody;
4457
4451
s = s.semanticNoScope(scd);
4458
4452
scd.pop();
4459
4453
return s;
0 commit comments