← Back to index
|
Original Bugzilla link
Bug 20724 – Compiler fails to infer @safe
Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-04-07T07:34:37Z
Last change time
2020-06-05T16:01:51Z
Assigned to
No Owner
Creator
Andrej Mitrovic
Comments
Comment #0
by andrej.mitrovich — 2020-04-07T07:34:37Z
----- public void hash (T) (scope const auto ref T record) // @safe // uncomment to compile if (is(T == struct)) { foreach (const ref field; record.tupleof) { hash(field); } } public void hash (T) (scope const auto ref T[] records) @safe { foreach (ref record; records) hash(record); } @safe void main () { struct Foo { Foo[] foo; } Foo foo; hash(foo); } ----- $ dmd test.d $ test.d(15): Error: @safe function test.hash!(Foo).hash cannot call @system function test.hash!(Foo).hash $ test.d(3): test.hash!(Foo).hash is declared here Uncommenting '@safe' makes it compile. The safety should have been inferred.
Comment #1
by snarwin+bugzilla — 2020-06-05T16:01:51Z
*** This issue has been marked as a duplicate of issue 7205 ***