www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Today's compiler error message

reply IchorDev <zxinsworld gmail.com> writes:
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
[...]
```

and switching the `alias` declaration for `enum` made it work.

Highly informative as always...
Jul 12 2023
parent reply Dennis <dkorpel gmail.com> writes:
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.
Jul 12 2023
parent reply IchorDev <zxinsworld gmail.com> writes:
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.
Jul 12 2023
parent reply Dennis <dkorpel gmail.com> writes:
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.
Jul 13 2023
parent reply IchorDev <zxinsworld gmail.com> writes:
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.
Jul 13 2023
parent reply Stefan Koch <uplink.coder googlemail.com> writes:
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
Jul 14 2023
parent IchorDev <zxinsworld gmail.com> writes:
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: ```d import B; mixin(" import foreign.code; alias x = foreign.code.y!false; "); ``` B: ```d import C; C.Type blabla; ``` C: ```d 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.
Jul 17 2023