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 21590 - assignment inside assert accepted for -checkaction=context #12165

Merged
merged 1 commit into from Jan 30, 2021

Conversation

MoonlightSentinel
Copy link
Contributor

@MoonlightSentinel MoonlightSentinel commented Jan 29, 2021

The rewrite introduced a temporary which hid the assignment inside of
assert(...) and hence prevented the error.

The fix is to omit the additional temporary for (Bin)AssignExp and use
the assigned variable directly. The temporary is unecessary anyways
and the following semantic analysis will raise an appropriate error.

@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
21590 regression assignment inside assert accepted if -checkaction=context is given

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

@Geod24
Copy link
Member

Geod24 commented Jan 29, 2021

This doesn't detect other kind of assignments, such as CatAssignExp, does it ?

@MoonlightSentinel
Copy link
Contributor Author

This doesn't detect other kind of assignments, such as CatAssignExp, does it ?

Fixed. But there is no error for those expressions at the moment (regardless of -checkaction=context)

@BorisCarvajal
Copy link
Member

Copy toBoolean() function from AssignExp to BinAssignExp, maybe that will work.

@MoonlightSentinel
Copy link
Contributor Author

Copy toBoolean() function from AssignExp to BinAssignExp, maybe that will work.

It does, but it also breaks a lot of code.

Boolean conversion for assignments is rejected because it's most likely a typo ( = vs ==), but this reasoning doe not apply to binary assignments (e.g. +=).

The rewrite introduced a temporary which hid the assignment inside of
`assert(...)` and hence prevented the error.

The fix is to omit the additional temporary for `AssignExp` and use
the assigned variable directly. The temporary is unecessary anyways
and the following semantic analysis will raise an appropriate error.
Copy link
Member

@Geod24 Geod24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Geod24 Geod24 merged commit 8055d9d into dlang:stable Jan 30, 2021
@MoonlightSentinel MoonlightSentinel deleted the checkaction-assign branch February 28, 2021 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants