Bug 17371 – [REG 2.074.0] di generation broken for anonymous classes

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-05-05T12:59:23Z
Last change time
2017-12-18T22:57:56Z
Assigned to
RazvanN
Creator
Jacob Carlborg

Comments

Comment #0 by doob — 2017-05-05T12:59:23Z
Generating a .di file with 2.074.0 from the following code generates a broken file: interface Foo {} class Bar { this() { auto foo = new class () Foo {}; } } The generated result is: interface Foo { } class Bar { this() { auto foo = new class class __anonclass1 : Foo { } ; } } The generated code for the anonymous class is clearly broken. With 2.073.1 the following code is generated: interface Foo { } class Bar { this(); } I suspect that generating the code for an anonymous class has always been broken, as the following example shows, generated with 2.073.1: Original code: interface Foo { } const foo = new class () Foo {}; Generated code: interface Foo { } const foo = new class class __anonclass1 : Foo { } ; Not sure if this is technically a regression but it broke my code switching to 2.074.0.
Comment #1 by razvan.nitu1305 — 2017-11-14T10:10:07Z
PR that caused it [1] . The header generation takes into account if a class is anonymous by invoking the final method Dsymbol.isAnonymous. The specified methods verifies if a symbol is anonymous by checking if the id is null, but when a class is instantiated with a null id, it generates one [2] thus scrambling things up. I think that the easiest way to fix this is to declare a new bool field (isanon) which is set to true when a null id is passed to the instantiation of a class declaration and the header generation can check for that field instead of the wrong isAnonymous method. PR coming soon. [1] https://github.com/dlang/dmd/pull/5565 [2] https://github.com/dlang/dmd/pull/5565/files#diff-ddbaa5e9ca3d5c90a425a9dfafaf1734R225
Comment #2 by razvan.nitu1305 — 2017-11-14T12:09:25Z
Comment #3 by github-bugzilla — 2017-11-27T16:48:25Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/a16826730fb7987d2012144cf7eaf46c53ae3735 Fix Issue 17371 - [REG 2.074.0] di generation broken for anonymous classes https://github.com/dlang/dmd/commit/64bbb4084db5cba159ceec9cb88512c5d1b64d02 Merge pull request #7315 from RazvanN7/Issue_17371 Fix Issue 17371 - [REG 2.074.0] di generation broken for anonymous classes merged-on-behalf-of: unknown
Comment #4 by github-bugzilla — 2017-12-18T22:57:56Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/a16826730fb7987d2012144cf7eaf46c53ae3735 Fix Issue 17371 - [REG 2.074.0] di generation broken for anonymous classes https://github.com/dlang/dmd/commit/64bbb4084db5cba159ceec9cb88512c5d1b64d02 Merge pull request #7315 from RazvanN7/Issue_17371