Bug 20602 – [REG2.086] ICE on wrong code

Status
RESOLVED
Resolution
WORKSFORME
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-02-23T21:05:37Z
Last change time
2020-09-06T13:10:46Z
Keywords
ice-on-invalid-code, industry
Assigned to
No Owner
Creator
johanengelen

Attachments

IDFilenameSummaryContent-TypeSize
17820001-fix-issue-20602-REG2.086-ICE-on-wrong-code.patchfix, targeting stabletext/plain2355

Comments

Comment #0 by johanengelen — 2020-02-23T21:05:37Z
Before 2.086 this code would simply error. But now it crashes the compiler. ``` import std; auto ggg(Func)(Func func) { func(); } nogc foo()() { } void someOp(T)() { try { } catch foo; try ggg(() => msg); catch boo; } struct S(T) { T slice() inout { someOp!int(); } void opAssign()(U) {} alias slice this; } struct ClusterInfo { @UDA() UUID guid; @UDA() S!(char) name; } ``` The original code triggering the crash was much more complex, but the compiler crashes at the same point. An assert is triggered; with LDC it is this assert: https://github.com/ldc-developers/ldc/blob/d7b4b7db1cc69b3c3e356eeaf3c136a71fa2f516/dmd/expressionsem.d#L1669
Comment #1 by b2.temp — 2020-05-04T15:02:35Z
The assertion looks irrelevant as the function it's located in is for the parameters. It seems that remiving the assertion and returning early if tf.next is null and that fd.inferReturnType is false works. Those two conditions mean that like in your test case the return type is not valid and an error is already emitted for that.
Comment #2 by b2.temp — 2020-05-04T15:17:32Z
Created attachment 1782 fix, targeting stable I have technical problems registering at GH si I cant propose the PR but the patch is verified to pass the test suite. Consider doing the remaining part of the job using $ git checkout -b issue-20602 $ git am 0001-fix-issue-20602-REG2.086-ICE-on-wrong-code.patch and then dont forget to target stable when using GH.
Comment #3 by johanengelen — 2020-09-06T13:10:46Z
Why "worksforme"? The crash is easily reproducible on e.g. godbolt.org. Do you instead mean that this has been fixed accidentally upstream? From which version?