[Issue 5155] [AA] AssociativeArray.get does not compile when opBinary("in") is defined.

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jul 21 00:32:14 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=5155

--- Comment #1 from Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> ---
(In reply to Rob Jacques from comment #0)
> As I can see no reason, type wise, for this to be so, this may be rooted
> in a DMD error.

How so?

The implementation of get() clearly contains:

    auto p = key in aa;

Here, the compiler correctly tries invoking opBinary!("in") on the left-hand
operand first, followed by opBinaryRight on the right-hand one.

I don't understand why you consider this to be a DMD error. The compiler is
correctly following the spec.

> Also, complex
> templates can cause an ICE: I found this bug after tracing down an instance
> of Issue 5079 (glue.c, 1103) due to a std.variant unit test instantiating
> This[This]. 

That would need to be filed separately.

> Lines 413:
> -        auto p = key in *cast(Value[Key]*)(&p);
> +        auto ptr = cast(Value*) _aaIn(p,typeid(Key),key);

This looks like it might be a small optimization, however it mainly looks like
a workaround for broken user code.

Associative arrays are planned to be converted to an entirely templated
implementation, so this patch will soon no longer be applicable either way.

Closing, per the arguments above, and as this issue is over 6 years old.

--


More information about the Digitalmars-d-bugs mailing list