[Issue 21800] New: Unused delegate template parameter scope incorrectly inferred
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 5 16:20:29 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21800
Issue ID: 21800
Summary: Unused delegate template parameter scope incorrectly
inferred
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: eyal at weka.io
This program fails to compile in the "ignore!..." line.
@nogc nothrow void ignore(alias F)() {}
@nogc nothrow void call(alias F)() { F(); }
@nogc
void main() {
int x;
ignore!(()=>x)(); // delegate causes "x" to come from GC
call!(()=>x)(); // is fine
}
It compiles fine if the "ignore!" line is commented out.
If a delegate is unused, surely its scope is at least as narrow as a delegate
that is used.
Why is @nogc inference not done on the template instantiation result?
--
More information about the Digitalmars-d-bugs
mailing list