Issue 24764 - ICE when -vcg-ast prints imported invariant
Summary: ICE when -vcg-ast prints imported invariant
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords: ice, pull
Depends on:
Blocks:
 
Reported: 2024-09-12 13:25 UTC by Dennis
Modified: 2024-11-16 23:27 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Dennis 2024-09-12 13:25:53 UTC
Reduced from `imported!"std.outbuffer"`:

```
// a.d
template imported()
{
    import imported = b;
}

alias x = imported!();
```

```
// b.d
struct O
{
    invariant() {}
}
```

When compiling `dmd -vcg-ast a.d` you get:

```
core.exception.AssertError@src/dmd/hdrgen.d(1863): Assertion failure
```

The code in question being:

```D
void visitInvariantDeclaration(InvariantDeclaration d)
    {
        if (hgs.hdrgen)
            return;
        if (stcToBuffer(buf, d.storage_class))
            buf.writeByte(' ');
        buf.writestring("invariant");
        if(auto es = d.fbody.isExpStatement())
        {
            assert(es.exp && es.exp.op == EXP.assert_); // FAILS, it's EXP.call
            buf.writestring(" (");
            (cast(AssertExp)es.exp).e1.expressionToBuffer(buf, hgs);
            buf.writestring(");");
            buf.writenl();
        }
        else
        {
            bodyToBuffer(d);
        }
    }
```
Comment 1 Dlang Bot 2024-10-03 10:48:13 UTC
@dkorpel created dlang/dmd pull request #16917 "Fix bugzilla 24764 - ICE when -vcg-ast prints imported invariant" fixing this issue:

- Fix bugzilla 24764 - ICE when -vcg-ast prints imported invariant

https://github.com/dlang/dmd/pull/16917
Comment 2 Dlang Bot 2024-10-03 11:47:25 UTC
dlang/dmd pull request #16917 "Fix bugzilla 24764 - ICE when -vcg-ast prints imported invariant" was merged into stable:

- c52c26276b6dc70054bbd6eac58c4d13445ab16b by Dennis Korpel:
  Fix bugzilla 24764 - ICE when -vcg-ast prints imported invariant

https://github.com/dlang/dmd/pull/16917
Comment 3 Dlang Bot 2024-10-07 09:00:29 UTC
dlang/dmd pull request #16967 "Rebase stable6" was merged into master:

- c58361f46f9a4b20d8933a397d1ca34db2a40b65 by Dennis:
  Fix bugzilla 24764 - ICE when -vcg-ast prints imported invariant (#16917)
  
  Co-authored-by: Dennis Korpel <dennis@sarc.nl>

https://github.com/dlang/dmd/pull/16967
Comment 4 Dlang Bot 2024-11-16 23:27:14 UTC
dlang/dmd pull request #17069 "Merge stable" was merged into master:

- e0259d92e7fada37ae5c8e784704056f8a5aefd0 by Dennis:
  Fix bugzilla 24764 - ICE when -vcg-ast prints imported invariant (#16917)
  
  Co-authored-by: Dennis Korpel <dennis@sarc.nl>

https://github.com/dlang/dmd/pull/17069