-
-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Issue 21753 - Struct literal with function literal member not allowed #12300
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// https://issues.dlang.org/show_bug.cgi?id=21753 | ||
|
||
struct Sample { | ||
int function() func1; | ||
int function() func2; | ||
} | ||
|
||
void noth(Sample smpl)() { | ||
static assert(smpl.func1() == 0); | ||
static assert(smpl.func2() == 1); | ||
} | ||
|
||
void main() { | ||
enum s = Sample( | ||
{ return 0; }, | ||
{ return 1; } | ||
); | ||
static assert(s.func1() == 0); | ||
static assert(s.func2() == 1); | ||
noth!(s)(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -618,6 +618,12 @@ static assert(funcd.mangleof == "_D6mangle5funcdFPFZNnZi"); | |
|
||
/***************************************************/ | ||
|
||
struct S21753 { void function() f1; } | ||
void fun21753(S21753 v)() {} | ||
alias fl21753 = (){}; | ||
static assert((fun21753!(S21753(fl21753))).mangleof == "_D6mangle__T8fun21753VSQv6S21753S1_DQBi10" ~ fl21753.stringof ~ "MFNaNbNiNfZvZQCaQp"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @BorisCarvajal: With LDC, I'm somehow getting
Any ideas? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The lambda on LDC has no attributes ('FZv' instead of 'FNaNbNiNfZv'). Also it misses a backreference because of that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thx so much! |
||
|
||
/***************************************************/ | ||
void main() | ||
{ | ||
test10077h(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing tests...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this code only happens inside a struct literal the function type is resolved and
e.td
is always null.What should I do? assert(0 or !e.td), comment out, just delete...