Bug 8414 – with statement causes linker error

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-22T15:02:00Z
Last change time
2013-02-18T09:59:11Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2012-07-22T15:02:15Z
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.
Comment #1 by salihdb — 2012-08-07T21:45:19Z
I think so not a bug, it's work: with (Enum) { if(matchAny(en, en1, en2)) "test-ok".writeln; }
Comment #2 by andrej.mitrovich — 2012-08-07T22:47:00Z
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)) { }
Comment #3 by salihdb — 2012-08-09T13:55:46Z
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...:)
Comment #4 by bearophile_hugs — 2012-11-04T14:31:23Z
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); }
Comment #5 by andrej.mitrovich — 2013-02-07T12:17:09Z
*** Issue 9470 has been marked as a duplicate of this issue. ***
Comment #6 by andrej.mitrovich — 2013-02-18T09:59:11Z
*** This issue has been marked as a duplicate of issue 6196 ***