digitalmars.D.bugs - [Issue 2344] New: Two wrong lookups for array functions
- d-bugmail puremagic.com Sep 07 2008
- d-bugmail puremagic.com Oct 10 2008
- d-bugmail puremagic.com Oct 10 2008
- d-bugmail puremagic.com Oct 10 2008
- d-bugmail puremagic.com Oct 20 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2344 Summary: Two wrong lookups for array functions Product: D Version: unspecified Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: andrei metalanguage.com size_t blah(int[] r) { return r.length; } struct A { int[] r; size_t blah() { return r.blah(); } } void main() { A a; a.blah; } The code above says: function test.A.blah () does not match parameter types (int[]) Error: expected 0 arguments, not 1 So it looks like the compiler first morphs r.blah() into blah(r), but then uses the local scope to look for blah. Therefore A.blah will be found, leading to the nonsensical call this.blah(r). Interestingly, if the parens are removed leaving r.blah, the lookup is still wrong but in a different way: Error: no property 'blah' for type 'int[]' So this time the call fails to start with. Both errors are bugs. The code should compile with and without parentheses. --
Sep 07 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2344 ------- Comment #1 from bugzilla digitalmars.com 2008-10-10 18:23 ------- This is an enhancement. Rewriting: array.foo as: .foo(array) rather than: foo(array) does the trick. --
Oct 10 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2344 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement --
Oct 10 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2344 ------- Comment #2 from andrei metalanguage.com 2008-10-10 20:34 ------- (In reply to comment #1)This is an enhancement. Rewriting: array.foo as: .foo(array) rather than: foo(array) does the trick.
Nah. The whole point was to have obj.foo work for arrays and other beasts. --
Oct 10 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2344 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #3 from bugzilla digitalmars.com 2008-10-20 22:21 ------- Fixed dmd 2.020 --
Oct 20 2008









d-bugmail puremagic.com 