diff --git a/compiler/src/dmd/expressionsem.d b/compiler/src/dmd/expressionsem.d index 6da3467d8b..5850610dde 100644 --- a/compiler/src/dmd/expressionsem.d +++ b/compiler/src/dmd/expressionsem.d @@ -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);