Pathological import symbol shadowing
Mathias LANG
geod24 at gmail.com
Wed Nov 18 16:23:05 UTC 2020
On Friday, 13 November 2020 at 22:57:03 UTC, H. S. Teoh wrote:
>
> D's import implementation was supposed to be designed to
> prevent symbol hijacking, but in this case it's falling flat on
> its face.
>
> Why can't we make it so that symbols that aren't explicitly
> named on the import line would add to existing overload sets
> instead of replacing them?
>
>
> T
Wouldn't *that* allow hijacking? Unless of course you remove
implicit conversions of parameters. If you have a `void
foo(short)` in a module, and you're using it from your main like
so: `foo(42);`, then suddenly, if overload sets were merged,
another import at the same level could introduce `void foo(int)`,
which would be a better match, and hijack the call, instead of
creating an error as done currently.
More information about the Digitalmars-d
mailing list