[Issue 8786] New: assert does not call "invariant()" function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Oct 9 01:37:45 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8786
Summary: assert does not call "invariant()" function
Product: D
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: monarchdodra at gmail.com
--- Comment #0 from monarchdodra at gmail.com 2012-10-09 01:19:41 PDT ---
According to http://dlang.org/class.html#Invariant
"The invariant can be checked when a class object is the argument to an
assert() expression, as: "
//----
Date mydate;
...
assert(mydate); // check that class Date invariant holds
//----
But I get:
//----
struct S
{
invariant(){}
}
void main()
{
S s;
assert(s);
}
//----
Error: expression s of type S does not have a boolean value
//----
IMO, behavior of assert should be:
1. Check for argument can be cast to bool. If yes, do it. The call should
trigger invariant check anyways.
2. Else, call invariant directly.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list