Bug 13934 – Cannot pass 'this' to function by reference
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-01-04T19:30:00Z
Last change time
2015-03-09T23:49:35Z
Assigned to
nobody
Creator
doob
Comments
Comment #0 by doob — 2015-01-04T19:30:33Z
The following code compiles with 2.066.1 but fails to compile with 2.067.0-b1:
void bar (ref Foo) {}
class Foo
{
void foo()
{
bar(this);
}
}
The errors message is:
main.d(7): Error: function main.bar (ref Foo _param_0) is not callable using argument types (Foo)
Comment #1 by k.hara.pg — 2015-01-05T12:56:43Z
It's an intended bugfix for the issue 13116.
'this' and 'super' should not be lvalues to avoid illegal rebindings.
See the detailed cases in the issue ticket.
Comment #2 by k.hara.pg — 2015-03-05T01:16:00Z
*** Issue 14244 has been marked as a duplicate of this issue. ***
Comment #3 by k.hara.pg — 2015-03-09T12:14:57Z
*** Issue 14262 has been marked as a duplicate of this issue. ***
Comment #4 by public — 2015-03-09T20:53:25Z
Quoting myself from issue that was closed as duplicate:
"While refusing to compile this seems legit and code clearly needs fixing, error message is not helpful at all. It should explain the issue and suggest a fix more clearly."
Meaningful error messages are very important minimize frustration from broken upgrade.
Looking into it.
Comment #5 by public — 2015-03-09T21:24:57Z
btw the fact that 3 different people have reported it as a bug should have been a clear sign that the fix wasn't done clear enough