You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'in' expression for AA calls KeyType.toHash/opEquals if exist, but not detected as GC usage even if these functions are not @nogc.
Example: (In this case, compiler should require that toHash/opEquals are @nogc.)
struct KeyType
{
int x;
size_t toHash() const @safe nothrow{ return x;}bool opEquals(in KeyType r) const{ return x == r.x;}
}
ulong func(ulong[KeyType] aa) @nogc
{
if (auto p = KeyType(10) in aa) // can call KeyType.toHash/opEquals
return *p;
return aa.length;
}
The text was updated successfully, but these errors were encountered:
stanislav.blinov commented on 2021-12-08T16:51:16Z
If we go by the spec: https://dlang.org/spec/garbage.html#op_involving_gc
it explicitly lists AA lookups as GC operations. That being said, AAs outright swallow attributes (see related issue). Regardless, if the specification is correct with regards to GC usage, in this case at the very least `func` shouldn't compile.
sinkuupump reported this on 2014-11-05T11:58:48Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=13688
CC List
Description
The text was updated successfully, but these errors were encountered: