[Issue 3630] New: bad error location in "has no effect in expression" error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 17 16:09:58 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3630

           Summary: bad error location in "has no effect in expression"
                    error
           Product: D
           Version: 1.051
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: thecybershadow at gmail.com


--- Comment #0 from Vladimir <thecybershadow at gmail.com> 2009-12-17 16:09:57 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list