digitalmars.D.bugs - [Issue 409] New: function resolving with global function if member matches
- d-bugmail puremagic.com (30/30) Oct 08 2006 http://d.puremagic.com/issues/show_bug.cgi?id=409
- d-bugmail puremagic.com (9/9) Oct 08 2006 http://d.puremagic.com/issues/show_bug.cgi?id=409
- d-bugmail puremagic.com (5/7) Oct 08 2006 http://d.puremagic.com/issues/show_bug.cgi?id=409
- d-bugmail puremagic.com (16/16) Oct 16 2006 http://d.puremagic.com/issues/show_bug.cgi?id=409
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 --
Oct 08 2006
http://d.puremagic.com/issues/show_bug.cgi?id=409 smjg iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg iname.com Keywords| |diagnostic There is in fact no match. But the error message is indeed confusing. --
Oct 08 2006
http://d.puremagic.com/issues/show_bug.cgi?id=409There is in fact no match. But the error message is indeed confusing.I wonder because it compiles without the method A.equals --
Oct 08 2006
http://d.puremagic.com/issues/show_bug.cgi?id=409 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID 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. --
Oct 16 2006