expressionsem.d remove goto (#16845)

This commit is contained in:
Nicholas Wilson 2024-09-21 13:27:30 +08:00 committed by GitHub
parent f4e21aec67
commit d578c61fc4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -665,6 +665,13 @@ Expression resolveOpDollar(Scope* sc, ArrayExp ae, Expression* pe0)
AggregateDeclaration ad = isAggregate(ae.e1.type);
Dsymbol slice = search_function(ad, Id.slice);
//printf("slice = %s %s\n", slice.kind(), slice.toChars());
Expression fallback()
{
if (ae.arguments.length == 1)
return null;
error(ae.loc, "multi-dimensional slicing requires template `opSlice`");
return ErrorExp.get();
}
foreach (i, e; *ae.arguments)
{
if (i == 0)
@ -672,11 +679,7 @@ Expression resolveOpDollar(Scope* sc, ArrayExp ae, Expression* pe0)
if (e.op == EXP.interval && !(slice && slice.isTemplateDeclaration()))
{
Lfallback:
if (ae.arguments.length == 1)
return null;
error(ae.loc, "multi-dimensional slicing requires template `opSlice`");
return ErrorExp.get();
return fallback();
}
//printf("[%d] e = %s\n", i, e.toChars());
@ -716,7 +719,7 @@ Expression resolveOpDollar(Scope* sc, ArrayExp ae, Expression* pe0)
sc = sc.pop();
global.endGagging(xerrors);
if (!fslice)
goto Lfallback;
return fallback();
e = new DotTemplateInstanceExp(ae.loc, ae.e1, slice.ident, tiargs);
e = new CallExp(ae.loc, e, fargs);