[Issue 22270] New: [DIP1000] class does infer scope in methods when assigned to a scope variable
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Sep 3 11:26:22 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22270
Issue ID: 22270
Summary: [DIP1000] class does infer scope in methods when
assigned to a scope variable
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: jlourenco5691 at gmail.com
The struct can infer scope, but the class cannot. There are ways to get around
this, but the behavior should be consistent.
---
struct Bar
{
@safe void dummy() {}
}
class Foo
{
@safe void dummy() {}
}
@safe
void main()
{
scope bar = new Bar;
bar.dummy; // ok
scope foo = new Foo;
foo.dummy(); // fails
}
---
To work around this issue, the class function must be annotated with scope, or
be a template.
--
More information about the Digitalmars-d-bugs
mailing list