Bug 23010 – mixed in aliaseqs used as type dont initualize

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-04-11T16:28:08Z
Last change time
2022-06-24T13:47:08Z
Keywords
pull
Assigned to
No Owner
Creator
crazymonkyyy

Comments

Comment #0 by crazymonkyyy — 2022-04-11T16:28:08Z
```d import std.meta; import std.stdio; mixin template faz(){ alias T=AliasSeq!(int); T bar=0; void write_(){ bar.writeln; } } void main(){ mixin faz!(); write_; }``` prints a random int not a 0
Comment #1 by moonlightsentinel — 2022-04-11T16:45:35Z
N.B.: This code used to trigger an assertion failure in the backend until 2.082.1
Comment #2 by dlang-bot — 2022-06-22T09:28:11Z
@BorisCarvajal created dlang/dmd pull request #14237 "Fix Issue 23010 - mixed in aliaseqs used as type don't initialize" fixing this issue: - Fix Issue 23010 - mixed in aliaseqs used as type don't initialize `TupleDeclaration` elements were inserted to the `members` array of current `ScopeDsymbol` but `TemplateMixin` declarations are already expanded in statement level and this confused DMD backend. After adding some code to insert tuple elements to `AggregateDeclaration.fields` and for parsing tuples in `toObjFile`, the code in question can be removed. No more hidden symbols (like `__tuple_field_0`) inside any `members` field. https://github.com/dlang/dmd/pull/14237
Comment #3 by dlang-bot — 2022-06-24T13:47:08Z
dlang/dmd pull request #14237 "Fix Issue 23010 - mixed in aliaseqs used as type don't initialize" was merged into master: - 5105b067bccb90399b183ec32c7b399c144d47aa by Boris Carvajal: Fix Issue 23010 - mixed in aliaseqs used as type don't initialize `TupleDeclaration` elements were inserted to the `members` array of current `ScopeDsymbol` but `TemplateMixin` declarations are already expanded in statement level and this confused DMD backend. After adding some code to insert tuple elements to `AggregateDeclaration.fields` and for parsing tuples in `toObjFile`, the code in question can be removed. No more hidden symbols (like `__tuple_field_0`) inside any `members` field. https://github.com/dlang/dmd/pull/14237