digitalmars.D.bugs - [Issue 6005] New: Type alias - variable name don't clash
- d-bugmail puremagic.com (50/50) May 15 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6005
http://d.puremagic.com/issues/show_bug.cgi?id=6005 Summary: Type alias - variable name don't clash Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: diagnostic Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc --- Comment #0 from bearophile_hugs eml.cc 2011-05-15 05:21:23 PDT --- This is D code adapted from a blog post about C language: http://eli.thegreenplace.net/2011/05/02/the-context-sensitivity-of-c%E2%80%99s-grammar-revisited/ http://www.reddit.com/r/programming/comments/h23h3/the_context_sensitivity_of_cs_grammar_revisited/ Three little D2 programs that compile with no errors. Similar code is allowed in C too: ------------ alias int Foo; void foo() { Foo bar; float Foo; } void main() {} ------------ alias int Foo; void foo() { Foo Foo; int bar = Foo + 2; assert (bar == 2); } void main() {} ------------ alias char Foo; void foo() { int bar = Foo.sizeof, Foo, spam = Foo.sizeof; assert(bar == 1); assert(spam == 4); } void main() {} ------------ Is it OK to keep allowing such kind of code in D2 too? Or is it better to statically forbid it? A disadvantage of statically disallowing it is the breakage of some valid C code. On the other hand I don't want to find code like that in D programs. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 15 2011