Bug 19422 – Associative arrays break inference of @safe, nothrow, pure

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-11-22T20:51:55Z
Last change time
2024-12-13T19:01:27Z
Assigned to
No Owner
Creator
Stanislav Blinov
See also
https://issues.dlang.org/show_bug.cgi?id=13688
Moved to GitHub: dmd#19512 →

Comments

Comment #0 by stanislav.blinov — 2018-11-22T20:51:55Z
struct S { int x; this(this) { /* do @system stuff... */ import std.stdio; writeln("copy"); } const: bool opEquals(S rhs) { return x == rhs.x; } size_t toHash() { return hashOf(x); } } void testS() @safe nothrow pure { S a; auto b = a; a.opEquals(b); auto h = a.toHash(); } void testAA() @safe nothrow pure { int[S] aa; S key; aa[key] = 0; } testS() will not compile since neither postblit, nor opEquals or toHash satisfy the attributes. But testAA() compiles, even though the AA implementation calls all the same functions.
Comment #1 by robert.schadek — 2024-12-13T19:01:27Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19512 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB