Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
December 01, 2010 [Issue 5297] New: The lookup order of recursive with statements is undefined. | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5297 Summary: The lookup order of recursive with statements is undefined. Product: D Version: unspecified Platform: Other OS/Version: All Status: NEW Severity: trivial Priority: P2 Component: websites AssignedTo: nobody@puremagic.com ReportedBy: blood.of.life@gmail.com --- Comment #0 from Bernard Helyer <blood.of.life@gmail.com> 2010-12-01 05:27:29 PST --- In implementing SDC I find myself asking these questions, and I wish to try and put and end to DMD being the sole definer of semantics; just letting you know the reason for this and subsequent bug reports. Given a series of with statements: with (a) with (b) with (c) { d(); } If all three objects have a method d(), then c gets called. Obviously the with statements are considered in a LIFO order, and the sentence http://www.digitalmars.com/d/2.0/statement.html#WithStatement "Use of with object symbols that shadow local symbols with the same identifier are not allowed. " does not apply here. Neither is documented behaviour, and the only to figure out how D behaves is to run DMD. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 01, 2010 [Issue 5297] The lookup order of recursive with statements is undefined. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bernard Helyer | http://d.puremagic.com/issues/show_bug.cgi?id=5297 Simen Kjaeraas <simen.kjaras@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |accepts-invalid CC| |simen.kjaras@gmail.com Component|websites |DMD Platform|Other |All Version|unspecified |D2 Severity|trivial |normal --- Comment #1 from Simen Kjaeraas <simen.kjaras@gmail.com> 2010-12-01 05:44:53 PST --- This is a compiler bug. Symbols used in with should shadow symbols from other with statements. You're right however, that the spec should state this. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 01, 2010 [Issue 5297] The lookup order of recursive with statements is undefined. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bernard Helyer | http://d.puremagic.com/issues/show_bug.cgi?id=5297 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #2 from bearophile_hugs@eml.cc 2010-12-01 12:39:36 PST --- (In reply to comment #1) > Symbols used in with should shadow symbols from other > with statements. Do you mean "shouldn't"? This shadowing is not detected, and I think the compiler has to flag this is as a compile error (just like it does with normal variables in the function stack frame): struct X { int a; } struct Y { int a; } void main() { X x; Y y; with (x) { a = 2; with (y) { a = 1; } } assert(x.a == 2); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 01, 2010 [Issue 5297] The lookup order of recursive with statements is undefined. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bernard Helyer | http://d.puremagic.com/issues/show_bug.cgi?id=5297 --- Comment #3 from Simen Kjaeraas <simen.kjaras@gmail.com> 2010-12-01 14:59:32 PST --- (In reply to comment #2) > (In reply to comment #1) > > Symbols used in with should shadow symbols from other > > with statements. > > Do you mean "shouldn't"? Yes and no. It shouldn't silently do so, but it should detect that that is what is happening, and cry out loudly. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 20, 2012 [Issue 5297] The lookup order of recursive with statements is undefined. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bernard Helyer | http://d.puremagic.com/issues/show_bug.cgi?id=5297 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla@digitalmars.com --- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2012-01-20 11:29:23 PST --- The spec looks correct to me. The lookup order is not undefined, each successive with introduces a new scope which overrides previous scopes. As for the shadowing, that is a bug in the compiler. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation