www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8414] New: with statement causes linker error

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

           Summary: with statement causes linker error
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



15:02:15 PDT ---
bool matchAny(T...)(T args) { return true; }
enum Enum { en1, en2 }

void main()
{
    Enum en;
    with (Enum)
    if (matchAny(en, en1, en2)) { }
}

C:\DOCUME~1\Andrej\LOCALS~1\Temp\.rdmd\rdmd-with_link_error.d-8483A5FE39E150DD5EE322E7B346449F\with_link_error-d-8483A5FE39E150DD5EE322E7B346449F.obj(with_link_error-d-8483A5FE39E15
DD5EE322E7B346449F) 
 Error 42: Symbol Undefined
_D4test49__T8matchAnyTE4test4EnumTE4test4EnumTE4test4EnumZ8matchAnyFE4test4EnumE4test4EnumE4test4EnumZb
--- errorlevel 1

It probably has something to do with name-mangling.

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


Salih Dincer <salihdb hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |salihdb hotmail.com
         Resolution|                            |INVALID



---
I think so not a bug,
it's work:

with (Enum) {
    if(matchAny(en, en1, en2))
        "test-ok".writeln;
}

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |



22:47:00 PDT ---
It's still a bug, if you use braces the bug isn't reproduced:

OK:
    with (Enum)
    {
        if (matchAny(en, en1, en2)) 
        { 
        }
    }

Linker error:
    with (Enum)
        if (matchAny(en, en1, en2)) 
        { 
        }

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




---
Okay, samples below can be read at compile-time error messages:

Sample-1:
void main()
{
    Enum en;

    with (Enum)  // <-- ERROR: found '}' instead of statement

}

Sample-2:
void main()
{
    Enum en;

    with (Enum); // <-- ERROR: use '{ }' for an empty statement, not a ';'

}

Well, this code is doing what you want! Yes, it's a linker bug...

void main()
{
    Enum en;

    with (Enum) // <-- NO ERROR!
    if(true) en1.writeln;
}

Surprised...:)

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


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



OK:

import std.algorithm;
enum Foo { A, B, C }
int main() {
    with (Foo) {
        return canFind([A, B, C], C);
    }
}



Linking error:

import std.algorithm;
enum Foo { A, B, C }
int main() {
    with (Foo)
        return canFind([A, B, C], C);
}

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |verylonglogin.reg gmail.com



12:17:09 PST ---
*** Issue 9470 has been marked as a duplicate of this issue. ***

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |DUPLICATE



09:59:11 PST ---
*** This issue has been marked as a duplicate of issue 6196 ***

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