View previous topic :: View next topic |
Author |
Message |
kihjin
Joined: 28 Dec 2006 Posts: 18
|
Posted: Fri Sep 14, 2007 7:26 pm Post subject: Class Invariants |
|
|
Hi-
The following piece of code renders an "error" on assert(true); but dmd compiles it just fine. Does Descent lack class invariant syntax support?
Code: | module Test;
class Test
{
this()
{
}
invariant
{
assert(true); // Shows as an error
}
}
|
I can deal with the error, I just wanted to see if this was an issue with Descent or if I've got something messed up locally. |
|
Back to top |
|
|
asterite
Joined: 01 Jun 2006 Posts: 235 Location: Buenos Aires, Argentina
|
Posted: Sat Sep 15, 2007 7:39 am Post subject: |
|
|
If youn compile that code with DMD 2.x you'll get that error. I guess you are compiling with DMD 1.x. If you are using DMD 1.x, go to the project's properties and in the D Compiler option select 1.x.
Also, if you generally develop in DMD 1.x, you can apply this setting to all projects by going to Windows -> Prefereces -> D -> Compiler and selecting 1.x.
In 2.x, you need to write:
invriant() {
assert(true);
}
because "invariant" in 2.x is also a modifier. |
|
Back to top |
|
|
kihjin
Joined: 28 Dec 2006 Posts: 18
|
Posted: Sat Sep 15, 2007 8:15 am Post subject: |
|
|
Ahhh. So invariant requires ()
I've been using the D docs that came with the DMD compiler locally. They are quicker to load than the ones on digitalmars.com. The class.html I have shows the invariant blockstatement without (), however on digitalmars' page http://www.digitalmars.com/d/class.html#Invariant it clearly shows invariant how you described.
I guess the packaged documentation needs to be updated. |
|
Back to top |
|
|
|