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: [email protected]
ReportedBy: [email protected]
--- Comment #0 from [email protected] 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: -------