digitalmars.D.learn - Are safe unittests actually checked for safety?
- 0xEAB (9/14) Sep 07 2020 Are unittests that are marked @safe actually checked for safety?
- Adam D. Ruppe (6/10) Sep 07 2020 I see what happened now: those nested functions are defined, but
Are unittests that are marked safe actually checked for safety? https://github.com/dlang/phobos/blob/v2.093.1/std/file.d#L4937 How comes this unittest is safe when `dirEntries` appears to be system? Example I: https://run.dlang.io/is/Vf0STwError: safe function onlineapp.listdir cannot call system function std.file.dirEntriesExample II (by adr):int* a = cast(int*) 0xdeadbeef; also was allowed.. making me think safe unittest doesn't actually check the safety- Elias PS: is there a safe version of `dirEntries`?
Sep 07 2020
On Monday, 7 September 2020 at 20:33:26 UTC, 0xEAB wrote:Are unittests that are marked safe actually checked for safety? https://github.com/dlang/phobos/blob/v2.093.1/std/file.d#L4937 How comes this unittest is safe when `dirEntries` appears to be system?I see what happened now: those nested functions are defined, but never actually called. The definition did NOT inherit the safe from the unittest, but since they were never called, it never actually mattered; the check happens on call, not on definition.
Sep 07 2020