D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20602 - [REG2.086] ICE on wrong code
Summary: [REG2.086] ICE on wrong code
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: ice-on-invalid-code, industry
Depends on:
Blocks:
 
Reported: 2020-02-23 21:05 UTC by johanengelen
Modified: 2020-09-06 13:10 UTC (History)
1 user (show)

See Also:


Attachments
fix, targeting stable (2.30 KB, patch)
2020-05-04 15:17 UTC, basile-z
Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description johanengelen 2020-02-23 21:05:37 UTC
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 basile-z 2020-05-04 15:02:35 UTC
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 basile-z 2020-05-04 15:17:32 UTC
Created attachment 1782 [details]
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 johanengelen 2020-09-06 13:10:46 UTC
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?