Bug 2940 – null is null cannot be evaluated at compile time

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2009-05-05T02:58:00Z
Last change time
2014-04-18T09:12:08Z
Keywords
patch, rejects-valid
Assigned to
bugzilla
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2009-05-05T02:58:55Z
static assert(null is null); --- bug.d(1): Error: static assert (null is null) is not evaluatable at compile t ime Whereas the code below compiles fine: int main(){ return (null is null); } --- This also applies to similar kinds of expressions, eg (null is typeid(int)). The patch for this relies on my patch for 1524, otherwise you get an ICE with "null is typeid(int)".
Comment #1 by clugdbug — 2009-05-05T03:01:44Z
PATCH in optimize.c, line 779, in IdentityExp::optimize(int result) Just allow TOKnull as one of the parameters. OLD: if (this->e1->isConst() && this->e2->isConst()) { e = Identity(op, type, this->e1, this->e2); } NEW: if ((this->e1->isConst() || this->e1->op == TOKnull) && (this->e2->isConst()|| this->e2->op == TOKnull)) { e = Identity(op, type, this->e1, this->e2); }
Comment #2 by tomas — 2009-05-05T06:35:44Z
Does things break if NullExp::isConst() was just implemented? After all, null is constant...
Comment #3 by bugzilla — 2009-09-03T13:25:00Z
Fixed dmd 1.047 and 2.032