Skip to content

Commit abe4ac1

Browse files
committed
Fix Issue 21753 - Struct literal with function literal member not allowed as template value argument
1 parent 98ec2d4 commit abe4ac1

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

src/dmd/dmangle.d

+8
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,14 @@ public:
12671267
}
12681268
}
12691269

1270+
override void visit(FuncExp e)
1271+
{
1272+
if (e.td)
1273+
mangleSymbol(e.td);
1274+
else
1275+
mangleSymbol(e.fd);
1276+
}
1277+
12701278
////////////////////////////////////////////////////////////////////////////
12711279

12721280
override void visit(Parameter p)

test/compilable/test21753.d

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// https://issues.dlang.org/show_bug.cgi?id=21753
2+
3+
struct Sample {
4+
int function() func1;
5+
int function() func2;
6+
}
7+
8+
void noth(Sample smpl)() {
9+
static assert(smpl.func1() == 0);
10+
static assert(smpl.func2() == 1);
11+
}
12+
13+
void main() {
14+
enum s = Sample(
15+
{ return 0; },
16+
{ return 1; }
17+
);
18+
static assert(s.func1() == 0);
19+
static assert(s.func2() == 1);
20+
noth!(s)();
21+
}

test/runnable/mangle.d

+6
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,12 @@ static assert(funcd.mangleof == "_D6mangle5funcdFPFZNnZi");
618618

619619
/***************************************************/
620620

621+
struct S21753 { void function() f1; }
622+
void fun21753(S21753 v)() {}
623+
alias fl21753 = (){};
624+
static assert((fun21753!(S21753(fl21753))).mangleof == "_D6mangle__T8fun21753VSQv6S21753S1_DQBi10" ~ fl21753.stringof ~ "MFNaNbNiNfZvZQCaQp");
625+
626+
/***************************************************/
621627
void main()
622628
{
623629
test10077h();

0 commit comments

Comments
 (0)