Bug 3630 – bad error location in "has no effect in expression" error
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2009-12-17T16:09:00Z
Last change time
2015-06-09T05:11:43Z
Keywords
diagnostic, pull
Assigned to
yebblies
Creator
dlang-bugzilla
Comments
Comment #0 by dlang-bugzilla — 2009-12-17T16:09:57Z
Consider:
=== Module a.d ===
enum { A, B, C }
=== Module b.d ===
import a;
// ... thousands of lines of code ...
void foo()
{
A;
}
// ... thousands of lines of code ...
==================
The error message outputted by the compiler will look like this:
a.d(1): Error: long has no effect in expression (0)
This is more serious considering that starting with 1.049, DMD forbids return expressions without side effects inside void functions. In my particular case, this was with the pretty-large DFL library, which required quite a bit of "divide-et-impera" to find the offending code.
By quickly looking at the compiler code, it looks like this happens because the expression statement is using the expression directly from the enumeration. The fix would involve instantiating an enum-reference expression each time an enumeration member is mentioned, or something like that.
Comment #1 by yebblies — 2011-06-12T23:19:46Z
*** Issue 3746 has been marked as a duplicate of this issue. ***
Comment #2 by yebblies — 2011-08-04T19:46:50Z
*** Issue 6233 has been marked as a duplicate of this issue. ***
Comment #6 by bearophile_hugs — 2012-02-20T19:45:51Z
I am seeing this, I don't know why:
dmc -c -Iroot;\dm\include -o -cpp func
e = p->type->defaultInitLiteral();
^
func.c(2488) : Error: 1 actual arguments expected for function, had 0
--- errorlevel 1
Comment #7 by yebblies — 2012-02-20T19:55:47Z
(In reply to comment #6)
> I am seeing this, I don't know why:
>
>
> dmc -c -Iroot;\dm\include -o -cpp func
> e = p->type->defaultInitLiteral();
> ^
> func.c(2488) : Error: 1 actual arguments expected for function, had 0
> --- errorlevel 1
Because Walter merged pull 41 which added that code. I'm glad I took away the default parameter, we just avoided a new missing line number bug.