[Issue 17879] UFCS can enable some forms of hijacking
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 6 13:13:42 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=17879
Steven Schveighoffer <schveiguy at yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |schveiguy at yahoo.com
--- Comment #4 from Steven Schveighoffer <schveiguy at yahoo.com> ---
According to the PR discussion, the issue was more like this:
mod1.d:
struct S {
// private string foo(){ return "hijacked"; }
}
main.d:
import mod1;
string foo(S s) { return "not hijacked"; }
void main() {
S s;
import std.stdio;
writeln(s.foo());
}
In other words, the *private* symbol was hijacking UFCS. S should be able to
build whatever it wants privately without interfering with UFCS.
When I try to build this now, it doesn't work anyway. I get both a deprecation
warning and an error. I can't figure out why the original code that the PR was
fixing actually worked before the PR.
I agree with Jonathan that UFCS just doesn't take precedent over the member,
and can't be considered a hijacking. If we "fixed" this, for instance, any code
that used output ranges might break.
However, allowing UFCS to provide unrelated added methods that the type has the
same name for, should work.
--
More information about the Digitalmars-d-bugs
mailing list