Bug 21886 – case where member function used as "alias this sym" is allowed without right `this` context

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-05-02T01:40:23Z
Last change time
2024-12-13T19:16:04Z
Keywords
accepts-invalid, spec
Assigned to
No Owner
Creator
basile-z
See also
https://issues.dlang.org/show_bug.cgi?id=19327
Moved to GitHub: dmd#19916 →

Comments

Comment #0 by b2.temp — 2021-05-02T01:40:23Z
This code compiles and runs. --- struct D { static int a; } struct C { int h; D get() { assert(h); assert(false); } alias get this; } void main(string[] args) { if (C.a){} } --- get() is not executed but in first place that should not compile as in C.a there's not valid this context.
Comment #1 by b2.temp — 2021-05-02T02:19:08Z
This is actually conform with the code of resolveAliasThis(), https://github.com/dlang/dmd/blob/b8ffb017c8c802827be98722b838cb120b9d918b/src/dmd/aliasthis.d#L83-L101 But the specs are not in sync with that.
Comment #2 by robert.schadek — 2024-12-13T19:16:04Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19916 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB