Skip to content
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 20989 - Checking array.ptr causes safety error ... #11337

Merged
merged 1 commit into from
Jul 4, 2020

Conversation

MoonlightSentinel
Copy link
Contributor

... with -checkaction=context.

Explicity flag DotIdExpressions as noderef because _d_assert_fail will not dereference the pointer and thus make the call @safe.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @MoonlightSentinel! 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
20989 minor Checking array.ptr causes safety error with -checkaction=context

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#11337"

@Geod24
Copy link
Member

Geod24 commented Jun 29, 2020

Nice!

@ghost
Copy link

ghost commented Jun 29, 2020

Sorry, little off-topic, this PR is nice but what has happened to our codecov check ?

@ibuclaw
Copy link
Member

ibuclaw commented Jun 29, 2020

Sorry, little off-topic, this PR is nice but what has happened to our codecov check ?

It's still being pushed by the circleci pipeline.

@nordlow
Copy link
Contributor

nordlow commented Jun 29, 2020

BTW, compiling

pure unittest
{
    int[] x;
    assert(x.ptr);
}

with -checkaction=context and running the test only prints

foo.d(4): [unittest] assert(x.ptr) failed

Wouldn't it be nice to print the value of x.ptr in this case?

@MoonlightSentinel
Copy link
Contributor Author

MoonlightSentinel commented Jun 29, 2020

Wouldn't it be nice to print the value of x.ptr in this case?

Indeed, thats why I've recently added support for unary expressions. It should be included in 2.093.0.

.\generated\windows\debug\64\dmd.exe -checkaction=context -main -unittest -run pretty_assert.d
pretty_assert.d(6): [unittest] 0x0 != true
....

... with -checkaction=context.

Explicity flag `DotIdExpressions` as `noderef` because `_d_assert_fail` will
not dereference the pointer and thus make the call `@safe`.
@MoonlightSentinel
Copy link
Contributor Author

This is ready for another review.

@Geod24 Geod24 merged commit 95be29f into dlang:stable Jul 4, 2020
@MoonlightSentinel MoonlightSentinel deleted the checkaction-ptr branch July 4, 2020 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants