-
-
Notifications
You must be signed in to change notification settings - Fork 636
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
Conversation
Thanks for your pull request, @BorisCarvajal! Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#12300" |
…owed as template value argument
I forgot user code test case. |
This adds an ambiguity to the grammar (https://dlang.org/spec/abi.html#Value needs an update, too). I tried adding the rule to https://gist.githubusercontent.com/rainers/6cdf73b48837defb9f88/raw/c948888769fc9c83a82eaa5b1069321d090fd303/dmangle.bison AFAICT the problem is that a mangled name does not have a terminator that is easy to detect. |
Wouldn't prefixing the symbol with its full length solve this then ? |
If I can trust bison, a prefix character 'f' is good enough. |
I did a few test mixing values with lambdas and its backrefs, the end of they were detected correctly but you are expert here, it's always better to make the grammar clean. |
I suspect the ambiguity can happen between the function return type being a struct (mangle starts with an 'S') and a following template parameter being a QualifiedName (starts with an 'S', too). |
override void visit(FuncExp e) | ||
{ | ||
if (e.td) | ||
mangleSymbol(e.td); |
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...
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 comment
The reason will be displayed to describe this comment to others. Learn more.
@BorisCarvajal: With LDC, I'm somehow getting
actual: _D6mangle__T8fun21753VSQv6S21753S1f_DQBj10__lambda71MFZvZQBtFNaNbNiNfZv
expected: _D6mangle__T8fun21753VSQv6S21753S1f_DQBj10__lambda71MFNaNbNiNfZvZQCbQp
Any ideas?
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.
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Thx so much!
…riding lambda function type Introduced in v0.15 (000663e). Removing this fixes a new test in runnable/mangle.d: dlang/dmd#12300 (comment)
… as template value argument