Bug 14283 – [2.067-b4]: Spurious "this is not an lvalue" deprecation message for "auto ref" arguments

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-03-14T09:06:00Z
Last change time
2015-06-17T21:02:13Z
Keywords
pull
Assigned to
nobody
Creator
sludwig

Comments

Comment #0 by sludwig — 2015-03-14T09:06:59Z
"auto ref" should deduce "this" argument to non-ref to avoid a deprecation message showing up for valid code. The original place where this was triggered was for std.typecons.scoped, where all arguments are declared as "auto ref". --- class C { void foo() { bar(this); } } void bar()(auto ref C) {} --- (3): Deprecation: this is not an lvalue
Comment #1 by code — 2015-03-15T13:19:50Z
*** Issue 14284 has been marked as a duplicate of this issue. ***
Comment #2 by code — 2015-03-15T16:06:10Z
It could be a bad idea to handle 'this' as lvalue (with deprecation) but infer and rvalue for auto ref. Also it required quite some hacking. I think a better choice is to keep it as lvalue but omit the deprecation message for auto ref parameters. In both cases I hardly expect any code breakage, as passing 'this' to an auto ref parameter hardly comprises the intent to change the this pointer.
Comment #3 by code — 2015-03-15T16:30:58Z
Comment #4 by github-bugzilla — 2015-03-15T22:37:19Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/6db86fdba070751ebbccede55b134aef1f791d46 fix Issue 14283 - spurious 'this' is not an lvalue deprecation for auto ref - suppress deprecation message for auto ref parameters as passing 'this' to auto ref will remain correct when it becomes an rvalue and because it's very unlikely that the passing as ref argument was intentional https://github.com/D-Programming-Language/dmd/commit/3bc3f1cd69d43db971a75a1ad36a04e2ac914fe9 Merge pull request #4497 from MartinNowak/fix14283 fix Issue 14283 - spurious 'this' is not an lvalue deprecation for auto ref
Comment #5 by github-bugzilla — 2015-03-16T17:00:59Z
Commit pushed to 2.067 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/56e59d841a3854afb8509f5930bfa4016fa7443d Merge pull request #4497 from MartinNowak/fix14283 fix Issue 14283 - spurious 'this' is not an lvalue deprecation for auto ref
Comment #6 by github-bugzilla — 2015-04-11T12:25:03Z
Comment #7 by github-bugzilla — 2015-06-17T21:02:13Z
Commits pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/6db86fdba070751ebbccede55b134aef1f791d46 fix Issue 14283 - spurious 'this' is not an lvalue deprecation for auto ref https://github.com/D-Programming-Language/dmd/commit/3bc3f1cd69d43db971a75a1ad36a04e2ac914fe9 Merge pull request #4497 from MartinNowak/fix14283