goto skips declaration of variable

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 18 07:22:36 PDT 2014


nrgyzer:

> import std.bigint;
> void main(string[] args)
> {
> 	BigInt i = "12345";
> 	if (args.length > 1)
> 	{
> 		goto Exit;
> 	}
> 	i = BigInt("67890");
> 	Exit:
> 		return;
> }
>
> When I try to compile this sample application I'm getting the 
> following error:
>
> sample.d(7): Error: goto skips declaration of variable 
> sample.main.__ctmp1344 at sample.d(9)

It looks like a compiler bug (perhaps caused by a rewrite rule). 
The 'i' variable is declared before the goto.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list