http://d.puremagic.com/issues/show_bug.cgi?id=4245
Summary: Declaring conflicting symbols in single function scope allowed Product: D Version: 2.041 Platform: x86 OS/Version: All Status: NEW Keywords: accepts-invalid, link-failure, patch Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: rsi...@gmail.com --- Comment #0 from Shin Fujishiro <rsi...@gmail.com> 2010-05-28 04:30:37 PDT --- Created an attachment (id=644) Patch for dmd svn r502 This code is correctly rejected: -------------------- test1.d void main() { { void foo() {} } { void foo() {} } } -------------------- % dmd test1 test1.d(4): Error: declaration foo is already defined in another scope in main -------------------- However the following is accepted and link fails due to the name conflict. -------------------- test2.d void main() { { typedef int T = 1; T v; assert(v == 1); } { struct T { int a = 2; } T v; assert(v.a == 2); } { union T { int a = 3; } T v; assert(v.a == 3); } { class T { int a = 4; } T v; assert(v.a == 4); } { enum T { a = 5 } T v; assert(v == 5); } } -------------------- % dmd test2 test2.o(.rodata+0x14): multiple definition of `_Dmain1T6__initZ' test2.o(.rodata+0x10): first defined here test2.o(.rodata+0x18): multiple definition of `_Dmain1T6__initZ' test2.o(.rodata+0x10): first defined here test2.o(.rodata+0x20): multiple definition of `_Dmain1T6__initZ' test2.o(.rodata+0x10): first defined here -------------------- The attached patch fixes the problem by rejecting such cases. -------------------- % dmd test2 test2.d(4): Error: declaration T is already defined in another scope in main test2.d(5): Error: declaration T is already defined in another scope in main test2.d(6): Error: declaration T is already defined in another scope in main test2.d(7): Error: declaration T is already defined in another scope in main -------------------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------