Bug 23451 – Static function declared in with scope cannot access property on type alias in with expression type

Status
NEW
Severity
minor
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-11-02T12:55:07Z
Last change time
2024-12-13T19:25:23Z
Keywords
industry
Assigned to
No Owner
Creator
FeepingCreature
Moved to GitHub: dmd#20175 →

Comments

Comment #0 by default_357-line — 2022-11-02T12:55:07Z
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`?
Comment #1 by robert.schadek — 2024-12-13T19:25:23Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20175 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB