Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Issue 22780 - [REG 2.090] variable reference to scope class must be scope #13667

Merged
merged 1 commit into from Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/dmd/dsymbolsem.d
Expand Up @@ -848,10 +848,9 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
}

// @@@DEPRECATED@@@ https://dlang.org/deprecate.html#scope%20as%20a%20type%20constraint
// Deprecated in 2.087
// Remove this when the feature is removed from the language
if (0 && // deprecation disabled for now to accommodate existing extensive use
!(dsym.storage_class & STC.scope_))
// Scope as a type constraint will soon be deprecated.
// Remove this when the feature is removed from the language.
if (!(dsym.storage_class & STC.scope_))
{
if (!(dsym.storage_class & STC.parameter) && dsym.ident != Id.withSym)
dsym.error("reference to `scope class` must be `scope`");
Expand Down
2 changes: 1 addition & 1 deletion test/compilable/test7172.d
Expand Up @@ -7,7 +7,7 @@ void main()
static assert(!__traits(compiles, { class D : FinalC{} }));

scope class ScopeC{}
// static assert(!__traits(compiles, { auto sc = new ScopeC(); }));
static assert(!__traits(compiles, { auto sc = new ScopeC(); }));
static assert( __traits(compiles, { scope sc = new ScopeC(); }));

synchronized class SyncC{ void f(){} }
Expand Down
12 changes: 12 additions & 0 deletions test/fail_compilation/fail22780.d
@@ -0,0 +1,12 @@
// https://issues.dlang.org/show_bug.cgi?id=22780
/* TEST_OUTPUT:
---
fail_compilation/fail22780.d(11): Error: variable `fail22780.test10717.c` reference to `scope class` must be `scope`
---
*/
scope class C10717 { }

void test10717()
{
C10717 c;
}