[Issue 1594] New: version not honored for invarient declaration
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Oct 18 22:19:17 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1594
Summary: version not honored for invarient declaration
Product: D
Version: 1.022
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: jemandy at earthlink.net
The following program does not compile in 1.022. The error message is
"invar.d(6): statement expected to be { }, not int".
import std.stdio;
version (D_Version2)
{
string str = "Version 2";
invariant int myint = 2;
}
else
{
string str = "Version 1";
const int myint = 1;
}
void main()
{
writefln( "str: %s\nmyint: %s", str, myint );
return;
}
Notice that a version 1 compiler shouldn't be trying to compile the statement
where the error occurs: it's in a block designated as being for a different
version of the compiler. Change the single occurrence of if "invariant" to
"const", and it compiles fine. With this change, the output of the program is
str: Version 1
myint: 1
just as you would hope.
--
More information about the Digitalmars-d-bugs
mailing list