Help with failing assert in dmd.backend.symbol.d
Teodor Dutu
teodor.dutu at gmail.com
Mon Sep 12 14:41:19 UTC 2022
On Friday, 2 September 2022 at 18:02:22 UTC, max haughton wrote:
> Try running gdb in follow fork mode, or run dub in verbose mode
> to get the dmd command.
>
> The backends knowledge of where things come from is terrible.
>
> For debugging the backend if it's not an obvious segfault or
> memory corruption etc you better get lucky with a printf or
> you're out of luck. It's an old and horrible codebase, the
> trees are simple enough but the algorithms were mostly designed
> before anything resembling modern compiler design practice.
>
> Feel free to ramble on the d slack about what you've tried so
> far.
Many thanks for the tips! I managed to debug the code and figured
out that the issue was not necessarily caused by my PR, but
merely exposed by it. I reduced the source of the bug to roughly
the code below:
```d
Tarr foo(Tarr : T[], T)(return scope Tarr x) { return x; }
struct S
{
import std.container.array : Array;
Array!int[] x;
Array!int[] bar()
{
return (foo(this.x[]), this.x[]);
}
}
```
[My
lowering](https://github.com/dlang/dmd/blob/7cef3b9f3c43151c5def069a5f281088f561d370/compiler/src/dmd/expressionsem.d#L10054) created a `CommaExp` similar to `foo(this.x[]), this.x[]`. The second `this.x[]` caused the backend to think that the symbol `this` was defined multiple times.
However, I cannot create a bug report with the above code,
because it does not compile in this form. `foo(this.x[]),
this.x[]` issues: `Error: Using the result of a comma expression
is not allowed`.
How would you recommend that I report this bug so it's easier to
reproduce?
More information about the Digitalmars-d
mailing list