Error about constructor calls in loops/labels, but there are no loops and labels?
Steven Schveighoffer
schveiguy at yahoo.com
Thu May 17 20:07:07 UTC 2018
On 5/17/18 4:02 PM, Steven Schveighoffer wrote:
> On 5/17/18 3:55 PM, DarkHole wrote:
>> This strange code - https://run.dlang.io/is/BKgv49 - fails with error
>> "Error: constructor calls not allowed in loops or after labels", but
>> there is no loops or labels.
>
> Switch cases are labels.
That being said, I don't understand the point of this restriction in
this case -- yes, it's after a label, but it's after the whole switch
construct. It's probably a conservative application of a rule.
You can fix by moving the final switch into a function:
https://run.dlang.io/is/352nIC
-Steve
More information about the Digitalmars-d
mailing list