Thread overview
[Issue 8414] New: with statement causes linker error
Jul 22, 2012
Andrej Mitrovic
Aug 08, 2012
Salih Dincer
Aug 08, 2012
Andrej Mitrovic
Aug 09, 2012
Salih Dincer
Feb 07, 2013
Andrej Mitrovic
Feb 18, 2013
Andrej Mitrovic
July 22, 2012
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


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-07-22 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-8483A5FE39E150DD5EE322E7B346449F)
 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: -------
August 08, 2012
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


--- Comment #1 from Salih Dincer <salihdb@hotmail.com> 2012-08-07 21:45:19 PDT ---
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: -------
August 08, 2012
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                     |


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-08-07 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: -------
August 09, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8414



--- Comment #3 from Salih Dincer <salihdb@hotmail.com> 2012-08-09 13:55:46 PDT ---
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: -------
November 04, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8414


bearophile_hugs@eml.cc changed:

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


--- Comment #4 from bearophile_hugs@eml.cc 2012-11-04 14:31:23 PST ---
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: -------
February 07, 2013
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


--- Comment #5 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-07 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: -------
February 18, 2013
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


--- Comment #6 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-18 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: -------