Skip to content

Commit

Permalink
[expressionsem.d] use nested function instead of goto
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilsonator committed Oct 5, 2024
1 parent 4d91765 commit 5c35d62
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -4113,6 +4113,11 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
ClassDeclaration cd;
Dsymbol s;

void err()
{
error(e.loc, "`super` is only allowed in non-static class member functions");
result = ErrorExp.get();

Check warning on line 4119 in compiler/src/dmd/expressionsem.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/expressionsem.d#L4118-L4119

Added lines #L4118 - L4119 were not covered by tests
}
/* Special case for typeof(this) and typeof(super) since both
* should work even if they are not inside a non-static member function
*/
Expand Down Expand Up @@ -4142,7 +4147,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
}
}
if (!fd)
goto Lerr;
return err();

Check warning on line 4150 in compiler/src/dmd/expressionsem.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/expressionsem.d#L4150

Added line #L4150 was not covered by tests

e.var = fd.vthis;
assert(e.var && e.var.parent);
Expand All @@ -4154,7 +4159,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
cd = s.isClassDeclaration();
//printf("parent is %s %s\n", fd.toParent().kind(), fd.toParent().toChars());
if (!cd)
goto Lerr;
return err();

Check warning on line 4162 in compiler/src/dmd/expressionsem.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/expressionsem.d#L4162

Added line #L4162 was not covered by tests
if (!cd.baseClass)
{
error(e.loc, "no base class for `%s`", cd.toChars());
Expand All @@ -4170,11 +4175,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
return setError();

result = e;
return;

Lerr:
error(e.loc, "`super` is only allowed in non-static class member functions");
result = ErrorExp.get();
}

override void visit(NullExp e)
Expand Down

0 comments on commit 5c35d62

Please sign in to comment.