Bug 24366 – [REG]static foreach can drop last element with alias reassignment

Status
NEW
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2024-02-01T20:03:57Z
Last change time
2024-12-13T19:32:58Z
Assigned to
No Owner
Creator
crazymonkyyy
Moved to GitHub: dmd#18210 →

Comments

Comment #0 by crazymonkyyy — 2024-02-01T20:03:57Z
alias seq(T...)=T; template foo(T...){ alias bar=seq!(); static foreach(i,A;T){ alias bar_(alias B:A)=bar; bar=seq!(bar_!A,A); } alias foo=bar; } void main(){ import std; alias foobar=foo!(int,bool,float); foobar.stringof.writeln; } expected: (int,bool,float) actaul: (int,bool) ``` 2.095.1 to 2.100.2: Success with output: (int, bool, float) Since 2.101.2: Success with output: (int, bool) ```
Comment #1 by destructionator — 2024-10-12T18:43:39Z
We identified the cause in OpenD as dsymbolsem.d look for "Try AliasSeq optimization" Commenting that out fixes the problem. // Try AliasSeq optimization /+ // actually don't because it is cause of https://issues.dlang.org/show_bug.cgi?id=24366 if (auto ti = ds.type.isTypeInstance()) { if (!ti.tempinst.findTempDecl(sc, null)) return errorRet(); if (auto tempinst = isAliasSeq(sc, ti)) { s = aliasAssignInPlace(sc, tempinst, aliassym); if (!s) return errorRet(); goto Lsymdone; } } +/
Comment #2 by robert.schadek — 2024-12-13T19:32:58Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18210 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB