dmd icon indicating copy to clipboard operation
dmd copied to clipboard

Use more robust pattern matching in Expression_optimize.visitAddr

Open nordlow opened this issue 3 years ago • 13 comments

nordlow avatar Apr 01 '22 07:04 nordlow

Thanks for your pull request and interest in making D better, @nordlow! 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

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

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 "master + dmd#13936"

dlang-bot avatar Apr 01 '22 07:04 dlang-bot

There are loads of other similar refactorings possible. Shall I look into these aswell? If so at what granularity should I split these up? By file, by function or by match expression?

nordlow avatar Apr 01 '22 07:04 nordlow

What is more robust about this? Test suite is failing.

dkorpel avatar Apr 01 '22 08:04 dkorpel

What is more robust about this? Test suite is failing.

Ok, I meant idiomatic. Gonna look into the test failure.

nordlow avatar Apr 01 '22 09:04 nordlow

@nordlow any progress on this?

RazvanN7 avatar Apr 25 '22 13:04 RazvanN7

@nordlow any progress on this?

I can't see what's wrong with my refactoring.

nordlow avatar May 11 '22 07:05 nordlow

I can't see what's wrong with my refactoring.

You changed if (ae.e2.isIntegerExp() && ae.e1.isVarExp()) to if (auto ie = ae.e2.isIntegerExp()), but there is a else branch below that is not taken now.

BorisCarvajal avatar May 11 '22 09:05 BorisCarvajal

I can't see what's wrong with my refactoring.

You changed if (ae.e2.isIntegerExp() && ae.e1.isVarExp()) to if (auto ie = ae.e2.isIntegerExp()), but there is a else branch below that is not taken now.

Ahh, thanks. I've adjusted things at https://github.com/dlang/dmd/commit/e73143415949b99f8f880f1b05969e958e5577a1. Had to increase identation. It's a pity github doesn't do a better job of reducing the diff in these cases.

nordlow avatar May 11 '22 09:05 nordlow

It's a pity github doesn't do a better job of reducing the diff in these cases.

There's a "Hide whitespace" option under the gear wheel. Still, I don't like this refactor, usually we want to reduce indentation. I don't see much wrong with the way it is now.

dkorpel avatar May 11 '22 09:05 dkorpel

It's a pity github doesn't do a better job of reducing the diff in these cases.

There's a "Hide whitespace" option under the gear wheel. Still, I don't like this refactor, usually we want to reduce indentation. I don't see much wrong with the way it is now.

My refactoring avoids redundant calls to isXXXExp functions.

If D supported a syntax similar to

if ((auto x = ...) && (auto y = ...))

we could avoid these extra levels of indentation.

nordlow avatar May 11 '22 09:05 nordlow

This looks like it has been abandoned and the need for this PR is doubtful anyway. I have added the 72h no response -> close label. @nordlow if you are able to make a case for this by then we can continue the discussion, otherwise I will close this.

RazvanN7 avatar May 27 '22 09:05 RazvanN7

Please rebase against master.

ljmf00 avatar May 28 '22 10:05 ljmf00

Yes @nordlow , please rebase.

RazvanN7 avatar Jun 09 '22 11:06 RazvanN7