Issue 24780 - Errors in Using "alias this = arr" within a Class
Summary: Errors in Using "alias this = arr" within a Class
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 All
: P1 major
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-09-23 07:52 UTC by mzfhhhh
Modified: 2024-09-23 07:52 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description mzfhhhh 2024-09-23 07:52:44 UTC
Errors in Using alias this = arr within a Class

```d
class A
{
    int [] arr;
    alias arr this; 
}

void main()
{
    A a = new A;
    a ~= 1;  
    writeln(a); // output: [1]
    writeln(a); // output err: []
}
```

When attempting to print the value of variable a for the second time, an error occurs, and the result is an empty array [].