Bug 23142 – Scope should not apply to unittests

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-05-27T05:23:38Z
Last change time
2022-06-09T15:17:38Z
Keywords
pull, safe
Assigned to
No Owner
Creator
Richard Cattermole

Comments

Comment #0 by alphaglosined — 2022-05-27T05:23:38Z
When declaring in a class or struct a unittest block should ignore any scope attributes set due to not having a context pointer. ```d void main() { } struct Foo { int x; scope: void func() { } unittest { } } ``` onlineapp.d(9): Error: function `onlineapp.Foo.__unittest_L9_C4` functions cannot be `scope` This error is not at all helpful and prevents a common use case for unittests as documentation without writing scope on every method which is very error-prone.
Comment #1 by dlang-bot — 2022-05-31T11:56:09Z
@dkorpel created dlang/dmd pull request #14177 "Fix issue 23142 - Scope should not apply to unittests" fixing this issue: - Fix issue 23142 - Scope should not apply to unittests https://github.com/dlang/dmd/pull/14177
Comment #2 by dlang-bot — 2022-06-09T15:17:38Z
dlang/dmd pull request #14177 "Fix issue 23142 - Scope should not apply to unittests" was merged into master: - 00d4d318b7a012dd23b5cd364f554048d2eaf89d by Dennis Korpel: Fix issue 23142 - Scope should not apply to unittests https://github.com/dlang/dmd/pull/14177