3630 – bad error location in "has no effect in expression" error

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3630 - bad error location in "has no effect in expression" error
Summary: bad error location in "has no effect in expression" error
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: yebblies
URL:
Keywords: diagnostic, pull
: 6233 (view as issue list)
Depends on:
Blocks:
Reported: 2009年12月17日 16:09 UTC by Vladimir Panteleev
Modified: 2015年06月09日 05:11 UTC (History)
5 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Vladimir Panteleev 2009年12月17日 16:09:57 UTC
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 yebblies 2011年06月12日 23:19:46 UTC
*** Issue 3746 has been marked as a duplicate of this issue. ***
Comment 2 yebblies 2011年08月04日 19:46:50 UTC
*** Issue 6233 has been marked as a duplicate of this issue. ***
Comment 3 yebblies 2012年02月20日 07:48:32 UTC
https://github.com/D-Programming-Language/dmd/pull/750 
Comment 4 github-bugzilla 2012年02月20日 18:24:49 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd
https://github.com/D-Programming-Language/dmd/commit/021f361bf01f91e76ccf2bc90483bce857149b54
Merge pull request #750 from yebblies/issue3630
Issue 3630 - bad error location in "has no effect in expression" error
Comment 5 github-bugzilla 2012年02月20日 19:09:59 UTC
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd
https://github.com/D-Programming-Language/dmd/commit/f3ab2da302e894498bd4cfc71cacda844c4f8120
fix Issue 3630 - bad error location in has no effect in expression error
Comment 6 bearophile_hugs 2012年02月20日 19:45:51 UTC
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 yebblies 2012年02月20日 19:55:47 UTC
(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.


AltStyle によって変換されたページ (->オリジナル) /