www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4058] New: Wrong error message with __traits(getMember

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4058

           Summary: Wrong error message with __traits(getMember
           Product: D
           Version: future
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2010-04-03 12:01:17 PDT ---
struct Test {
    void hello() {}
}
void main() {
    Test t;
    string m = "hello";
    __traits(getMember, t, m)(); // line 7
}


dmd 2.042 gives:

test.d(7): Error: string expected as second argument of __traits getMember
instead of m
test.d(7): Error: function expected before (), not false of type bool


Defining m as const,immutable or enum string avoids this error. So those two
error messages are bad. Something better can be:

test.d(7): Error: the second argument of __traits getMember must be a not
mutable string.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 03 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4058


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |FIXED


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-10-20
08:48:55 PDT ---
It now gives this generic error first:
test.d(7): Error: variable m cannot be read at compile time

I think that's clearer now.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 20 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4058


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |WORKSFORME


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 01 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4058



--- Comment #2 from bearophile_hugs eml.cc 2013-01-01 19:44:47 PST ---
Now this code:


struct Test {
    void hello() {}
}
void main() {
    Test t;
    string m = "hello";
    auto x = __traits(getMember, t, m); // line 7
}


Prints:

test2.d(7): Error: variable m cannot be read at compile time
test2.d(7): Error: string expected as second argument of __traits getMember
instead of m

I think the second error message should be inhibited, but this situation is
acceptable.

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