[Issue 21379] New: UDA's implemented with functions and taking alias params don't compile
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Nov 12 09:11:18 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21379
Issue ID: 21379
Summary: UDA's implemented with functions and taking alias
params don't compile
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: feco.graczer at gmail.com
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 () {}
}
--
More information about the Digitalmars-d-bugs
mailing list