Thread overview
Today's compiler error message
Jul 12
IchorDev
Jul 12
Dennis
Jul 12
IchorDev
Jul 13
Dennis
Jul 13
IchorDev
Jul 18
IchorDev
July 12

While writing some mixins I accidentally used alias instead of enum for a string manifest constant.
Compiling with GDC helped me locate the issue, as it gave an appropriate error message:

error: alias ‘bgfx.Attachment._init1094248_mangleof’ cannot alias an expression ‘"_ZN4bgfx10Attachment4initENS_13TextureHandleENS_6Access4EnumEttth"’
[...]

DMD and LDC2, however, decided that the real problem was an unmarked lambda placed within a mixin statement at module-scope:

../bindbc-bgfx/source/bgfx/package.d:1906:17: error: array literal in ‘@nogc’ function ‘bgfx.Resolution.__lambda18’ may cause a GC allocation
[...]

bgfx.Resolution ends at line #1097. The lambda is not @nogc, and switching the alias declaration for enum made it work.

Highly informative as always...

July 12

On Wednesday, 12 July 2023 at 15:53:39 UTC, IchorDev wrote:

>

DMD and LDC2, however, decided that the real problem was an unmarked lambda placed within a mixin statement at module-scope:

Do you have a test case that reproduces it? I tried:

alias y = mixin("``");

But that gives the "alias y cannot alias an expression """ error.

July 12
On Wednesday, 12 July 2023 at 16:00:34 UTC, Dennis wrote:
> On Wednesday, 12 July 2023 at 15:53:39 UTC, IchorDev wrote:
>> DMD and LDC2, however, decided that the real problem was an unmarked lambda placed within a mixin statement at module-scope:
>
>
> Do you have a test case that reproduces it? I tried:
>
> ```D
> alias y = mixin("``");
> ```
>
> But that gives the "alias `y` cannot alias an expression `""`" error.

No, I simply don’t have the time for that. Compiler oddities tend to be very painful to narrow down.
The code is more like…
mixin(“alias y = `”~someFn.mangleof~”`;”);
mixin(“someOtherFn(…, y);”);

But I doubt that’s enough to recreate it either.
July 13
On Wednesday, 12 July 2023 at 21:52:08 UTC, IchorDev wrote:
> No, I simply don’t have the time for that.

Is the code base public by any chance?

> The code is more like…
> mixin(“alias y = `”~someFn.mangleof~”`;”);

That gives a parse error inside the mixin, since a string literal is not allowed in that position.

July 13
On Thursday, 13 July 2023 at 10:41:06 UTC, Dennis wrote:
> On Wednesday, 12 July 2023 at 21:52:08 UTC, IchorDev wrote:
>> No, I simply don’t have the time for that.
>
> Is the code base public by any chance?
>

Not that version of it. Some of the code was meh, so I've already replaced a lot of it now. There's several layers of possible causes for such a strange error, I don't think anyone could repro. it very easily.
July 14
On Thursday, 13 July 2023 at 10:54:30 UTC, IchorDev wrote:
> On Thursday, 13 July 2023 at 10:41:06 UTC, Dennis wrote:
>> On Wednesday, 12 July 2023 at 21:52:08 UTC, IchorDev wrote:
>>> No, I simply don’t have the time for that.
>>
>> Is the code base public by any chance?
>>
>
> Not that version of it. Some of the code was meh, so I've already replaced a lot of it now. There's several layers of possible causes for such a strange error, I don't think anyone could repro. it very easily.

Do you know how to use the dustmite tool?
[https://github.com/CyberShadow/DustMite]
If not please get familiar with it and reduce the bug in your codebase.

Cheers,
Stefan
July 18

On Friday, 14 July 2023 at 07:58:36 UTC, Stefan Koch wrote:

>

Do you know how to use the dustmite tool?
[https://github.com/CyberShadow/DustMite]
If not please get familiar with it and reduce the bug in your codebase.

Cheers,
Stefan

Never used it before.
I had an issue yesterday where an alias from a mixin was not being found by a module that was being used by an import of the module where the alias was declared. Like this:

A:

import B;
mixin("
import foreign.code;
alias x = foreign.code.y!false;
");

B:

import C;

C.Type blabla;

C:

import A;

struct Type{}

A.x(); //ERROR! Undefined identifier!

Perhaps DustMite would be good for reducing this kind of error to its components as well. I’ll look into it if I find any more weird ones. :)

I think we need a dedicated thread for sharing obtuse compiler messages, alongside what the actual error ended up being. Often the compilers really just doesn’t understand how to tell us what we did wrong. Especially if the error is a bit weird, like a missing quote.