February 04, 2012 [Issue 7355] inout incorrectly resolved if the same type has both mutable and immutable parts | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=7355 --- Comment #20 from timon.gehr@gmx.ch 2012-02-04 10:05:05 PST --- (In reply to comment #19) > (In reply to comment #18) > > (In reply to comment #17) > > > try at a minimum immutable, mutable, and inout. If more than one of these typechecks, the call is ambiguous. > > > > What if one is a better match than the other? If it should fail I think we should use the repaired overload resolution. It has exactly the required semantics. > > Example? How can immutable match "better" than mutable? I guess it would depend on the definition of "better". class A{ A x()const{return new A;} alias x this; } int foo(immutable(A) x){return 1;} int foo(A x){return 2;} static assert(foo(new immutable(A)) == 1); The overload is resolved to the first function because it is an exact match whereas the second overload is a match with implicit conversions. Your proposed rules would always use the alias this when matching an inout(A) parameter, and that is probably not what is wanted. Interestingly, the compiler currently seems to explore the alias this of the alias this of the alias this... and never terminates. (Also see issue 7437). -- 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