Bug 21379 – UDA's implemented with functions and taking alias params don't compile

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-11-12T09:11:18Z
Last change time
2024-12-13T19:12:39Z
Assigned to
No Owner
Creator
Daniel
Moved to GitHub: dmd#19819 →

Comments

Comment #0 by feco.graczer — 2020-11-12T09:11:18Z
public struct TestX(alias ST) { alias serializer = ST; } TestX!ST resultSerializer (alias ST) () { return TestX!ST(); } // this compiles, no problem @resultSerializer!(function (string){return "hello";})() void f () {} class X { // this one doesn't compile @resultSerializer!(function (string){return "hello";})() void f () {} } compiler error message for the UDA of X.f: function tests.X.resultSerializer!(function (string) { return "hello"; } ).resultSerializer need this to access member resultSerializer The workaround was to not use functions to implement UDA, but to create a class to implement it: public struct ResultSerializer(alias ST) { alias serializer = ST; } @ResultSerializer!(function (string){return "hello";})() void f () {} class X { @ResultSerializer!(function (string){return "hello";})() void f () {} }
Comment #1 by feco.graczer — 2020-11-12T09:57:17Z
DMD64 D Compiler v2.094.0
Comment #2 by feco.graczer — 2020-11-12T11:19:33Z
sorry, compiler was DMD v2.093.1 (with ldc2)
Comment #3 by robert.schadek — 2024-12-13T19:12:39Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19819 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB