Thread overview |
---|
October 08, 2006 [Issue 409] New: function resolving with global function if member matches | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=409 Summary: function resolving with global function if member matches Product: D Version: 0.166 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: benoit@tionex.de bool equals( char[] a, char[] b ){ return a==b; } class A{ bool equals( A other ){ return this is A; } void func(){ char[] a1 = "a"; a1.equals( "b"[] ); // line 11 } } I get this error: t.d(11): function t.A.equals (A) does not match argument types (char[],char[]) t.d(11): Error: expected 1 arguments, not 2 t.d(11): cannot implicitly convert expression (a1) of type char[] to t.A -- |
October 09, 2006 [Issue 409] function resolving with global function if member matches | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=409 smjg@iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg@iname.com Keywords| |diagnostic ------- Comment #1 from smjg@iname.com 2006-10-08 19:50 ------- There is in fact no match. But the error message is indeed confusing. -- |
October 09, 2006 [Issue 409] function resolving with global function if member matches | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=409 ------- Comment #2 from benoit@tionex.de 2006-10-08 20:14 ------- (In reply to comment #1) > There is in fact no match. But the error message is indeed confusing. > I wonder because it compiles without the method A.equals -- |
October 16, 2006 [Issue 409] function resolving with global function if member matches | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=409 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #3 from bugzilla@digitalmars.com 2006-10-16 04:27 ------- It's working as designed. a1.equals("b"[]) is first rewritten as equals(a1,"b"[]), because a1 is an array. Then, "equals" is looked for in the enclosing scopes. The first one found is A.equals. The arguments are (a1,"b"[]) which are types (char[],char[]), which do not match (A), the argument types for A.equals. Hence the error message. If A.equals is removed, then the global equals is found, which does match the argument types. Not a bug. -- |
Copyright © 1999-2021 by the D Language Foundation