Bug 2840 – Missing line number for int %= complex (D1 only)

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2009-04-16T03:45:00Z
Last change time
2014-04-18T09:12:06Z
Keywords
diagnostic
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2009-04-16T03:45:58Z
void main(){ int x; x %= 2+2i; } fog.d(3): Error: cannot perform modulo complex arithmetic Error: long has no effect in expression (0) --- I don't know where the 'long' comes from. Both D1 and D2. This is one of the many op= bugs for erroneous complex operations, along with issue #718 and issue #2839.
Comment #1 by clugdbug — 2009-06-09T16:38:34Z
Root cause: ErrorExp() should not generate more error messages (ErrorExp never has a line number). PATCH: Solve it for all expression error messages. expression.c, line 948 void Expression::error(const char *format, ...) { + if (type==Type::terror) return; va_list ap; va_start(ap, format); ::verror(loc, format, ap); va_end( ap ); }
Comment #2 by fvbommel — 2009-06-10T02:52:34Z
Don, you may want to look at mtype.c, line 224. "basic[Terror] = basic[Tint32]". That's right, Type::terror == Type::tint32. (This is why 'int' shows up in so many error messages) So your patch would disable errors for any expression that's legitimately of type int. In order to fix it this way, you'd need to also introduce a separate error type. (Which I'm sure many people would appreciate if done properly, by the way)
Comment #3 by clugdbug — 2009-06-10T17:21:46Z
Aargh! You're right. That's useless! That defeats the whole purpose of an error type. It also makes ErrorExp() completely erroneous, because it's just an integer expression without line number! (there's no Loc in the constructor). I think there's at least one other patch I've submitted which is invalid for the same reason. There definitely needs to be an error type. It would take a lot of familiarity with the code to be able to make one, though.
Comment #4 by clugdbug — 2010-06-14T04:33:01Z
Fixed DMD2.062.
Comment #5 by clugdbug — 2010-06-14T04:33:26Z
Fixed DMD1.062.