[Issue 23451] New: Static function declared in with scope cannot access property on type alias in with expression type
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 2 12:55:07 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23451
Issue ID: 23451
Summary: Static function declared in with scope cannot access
property on type alias in with expression type
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: minor
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: default_357-line at yahoo.de
Consider the following code:
struct Foo {
alias Bar = Object;
}
void main() {
with (Foo()) {
static void baz() {
// this works
auto a = new Bar;
// this doesn't?
auto b = Bar.classinfo;
}
}
}
DMD claims:
onlineapp.d(11): Error: `static` function `onlineapp.main.baz` cannot access
variable `__withSym` in frame of function `D main`
But it doesn't need the frame, because it's accessing a type alias, and it
knows this when doing `new Bar`, but somehow not when doing `Bar.classinfo`?
--
More information about the Digitalmars-d-bugs
mailing list