dmd icon indicating copy to clipboard operation
dmd copied to clipboard

fix issue 20655 - attribute inference accepts unsafe union access as …

Open aG0aep6G opened this issue 5 years ago • 18 comments

…@safe

aG0aep6G avatar Mar 09 '20 23:03 aG0aep6G

Thanks for your pull request and interest in making D better, @aG0aep6G! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
20655 regression [REG: 2.072] attribute inference accepts unsafe union access as @safe

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "stable + dmd#10884"

dlang-bot avatar Mar 09 '20 23:03 dlang-bot

This is blocked by issue 20661, which is triggered more easily with this PR, but is also present without.

aG0aep6G avatar Mar 10 '20 11:03 aG0aep6G

I just ran into this issue, while building code for my dconf 2020 talk. What is the status of this?

schveiguy avatar Oct 03 '20 04:10 schveiguy

What is the status of this?

Still blocked by issue 20661.

aG0aep6G avatar Oct 03 '20 09:10 aG0aep6G

I have created: https://github.com/dlang/dmd/pull/12207 . Hope it unblocks this.

RazvanN7 avatar Feb 18 '21 16:02 RazvanN7

@aG0aep6G #12207 was merged. Maybe you can have another look at this?

RazvanN7 avatar Mar 02 '21 13:03 RazvanN7

@aG0aep6G #12207 was merged. Maybe you can have another look at this?

That fix is in stable, but it's not in master yet. I'm targeting master here. Let me know if you want me to switch to stable. Otherwise, we'll have to wait until your fix hits master.

aG0aep6G avatar Mar 02 '21 21:03 aG0aep6G

Since this PR fixes a regression, procedure dictates that it should target stable.

RazvanN7 avatar Mar 03 '21 08:03 RazvanN7

now targeting stable

aG0aep6G avatar Mar 03 '21 11:03 aG0aep6G

This PR seems to break phobos.

RazvanN7 avatar Mar 03 '21 12:03 RazvanN7

This PR seems to break phobos.

A reduced version of what's failing:

enum isAssignable(alias T) = false;

struct Unique
{
    alias ValueType = typeof({ return a; }()); /* Error: circular `typeof` definition */
    static if (isAssignable!ValueType) {}
    int* a;
}

I'm not sure that's supposed to work. With int a;, the code is rejected with "Error: need this for a of type int". I don't see why it should work with a pointer.

aG0aep6G avatar Mar 03 '21 19:03 aG0aep6G

Plot twist. This compiles:

enum isAssignable(alias T) = false;

struct Unique
{
    int a;
    alias ValueType = typeof({ return a; }()); /* Error: circular `typeof` definition */
    static if (isAssignable!ValueType) {}

}

This shows that the code should probably compile with both int and int*.

RazvanN7 avatar Mar 04 '21 09:03 RazvanN7

If typeof({ return a; }()) must work, then I'm afraid this issue is getting too complex for me to fix.

aG0aep6G avatar Mar 04 '21 11:03 aG0aep6G

Maybe you can file this as a bug report and I will take a look at it hopefully next week.

RazvanN7 avatar Mar 04 '21 11:03 RazvanN7

Maybe you can file this as a bug report and I will take a look at it hopefully next week.

Filed: https://issues.dlang.org/show_bug.cgi?id=21680

Note that fixing it doesn't necessarily unblock me here. If we consider issue 21680 a rejects-valid bug (which I think you're leaning towards), then I'm blocked here by my lack of DMD expertise, not by that issue.

aG0aep6G avatar Mar 04 '21 11:03 aG0aep6G

Thanks! I'm hoping that fixing that issue will make the phobos compile with this patch. I'll have to investigate further.

RazvanN7 avatar Mar 04 '21 15:03 RazvanN7

@aG0aep6G could you please rebase this?

RazvanN7 avatar Dec 03 '21 09:12 RazvanN7

@aG0aep6G could you please rebase this?

rebased

aG0aep6G avatar Dec 03 '21 20:12 aG0aep6G

@aG0aep6G still interested in getting this over the finish line?

ibuclaw avatar Jan 15 '23 14:01 ibuclaw

@aG0aep6G still interested in getting this over the finish line?

no

aG0aep6G avatar Jan 16 '23 13:01 aG0aep6G

Rebooted here: https://github.com/dlang/dmd/pull/14827

dkorpel avatar Jan 16 '23 13:01 dkorpel