Bug 16500 – inferred != annotated pure

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-09-16T13:29:46Z
Last change time
2024-12-13T18:50:08Z
Assigned to
No Owner
Creator
Bolpat
See also
https://issues.dlang.org/show_bug.cgi?id=22614
Moved to GitHub: dmd#19192 →

Comments

Comment #0 by qs.il.paperinik — 2016-09-16T13:29:46Z
struct X(T) { this(S)(in S[] arr) // inferred pure { } } void main() pure { X!uint mut = [ 1, 2 ]; // proves inference (cf. main is pure) // immutable X!uint imm1 = [ 1, 2 ]; // auto imm2 = immutable X!uint([1, 2]); } The last lines don't compile. However, they do if the inferred pure is explicitly annotated. From the discussion https://forum.dlang.org/post/[email protected]
Comment #1 by stanislav.blinov — 2021-12-21T18:44:55Z
I would strongly suggest constructors which are inferred pure, as opposed to explicitly annotated, MUST NOT be considered for uniqueness. Doing otherwise can lead to unexpected changes in program behavior, silent bugs. See the related issue for rationale.
Comment #2 by robert.schadek — 2024-12-13T18:50:08Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19192 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB