Today's compiler error message

IchorDev zxinsworld at gmail.com
Wed Jul 12 15:53:39 UTC 2023


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...


More information about the Digitalmars-d mailing list