D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19936 - Deprecated alias get this falsely triggers on appending to array
Summary: Deprecated alias get this falsely triggers on appending to array
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 regression
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2019-06-03 08:02 UTC by FeepingCreature
Modified: 2019-06-04 09:57 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description FeepingCreature 2019-06-03 08:02:26 UTC
Consider the following code:

struct Bla
{
    deprecated("bla")
    int get() { return 5; }
    
    alias get this;
}

void main()
{
    Bla[] blaArray;
    blaArray ~= Bla();
}

There is no reason that appending to Bla[] should justify an access to the deprecated get() function. And yet, when compiled with `-de`, `blaArray ~= Bla()` errors with a deprecation error. Note that this does not happen with `blaArray ~ Bla()`.
Comment 1 FeepingCreature 2019-06-03 08:04:49 UTC
Oh, and it's a regression too (since 2.084.1).
Comment 2 Dlang Bot 2019-06-03 08:51:16 UTC
@FeepingCreature created dlang/dmd pull request #9953 "Fix issue 19936: `alias deprecated get this` falsely triggers deprecation on `array ~=`" fixing this issue:

- Fix issue 19936: don't attempt alias-this for the rhs of an opAppend overload if no applicable overload was found in the lhs.

https://github.com/dlang/dmd/pull/9953
Comment 3 Dlang Bot 2019-06-04 09:57:46 UTC
dlang/dmd pull request #9953 "[REG 2.084.1] Fix issue 19936: `alias deprecated get this` falsely triggers deprecation on `array ~=`" was merged into stable:

- 1885840b3151eae627a2127d055437b2ea2ac357 by Mathis Beer:
  Fix issue 19936: don't attempt alias-this for the rhs of an opAppend overload if no applicable overload was found in the lhs

https://github.com/dlang/dmd/pull/9953