Bug 18487 – wrong warning: `A unittest should be annotated with at least @safe or @system`

Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2018-02-22T06:07:50Z
Last change time
2018-02-22T06:27:02Z
Assigned to
No Owner
Creator
Timothee Cour

Comments

Comment #0 by timothee.cour2 — 2018-02-22T06:07:50Z
``` nothrow @safe pure: // ... unittest { // ... } ``` std/array/static_array.d(43:1)[warn]: A unittest should be annotated with at least @safe or @system this is wrong since header has `nothrow @safe pure:` (likewise if i use `nothrow: @safe: pure:) (appeared in https://github.com/dlang/phobos/pull/6178 https://circleci.com/gh/dlang/phobos/6198?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link )
Comment #1 by greeenify — 2018-02-22T06:27:02Z
That's not a bug, but a feature. The idea is that reviewers see that a unittest is @system or @safe and can point out cases where the test should have been @safe. Also in a diff you typically don't see the module-level attributes + unittests are by default @system and yes we enforce the annotation in order to raise awareness of annotating the unittests. I see the the point to extend it for module-level attributes, but that's not how this check was intended to be. Hence, I am closing this as WONTFIX. BTW - module-level attributes are very seldomly used at Phobos because they make reviewing really tricky - this is the wrong component, it's a DScanner check