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 issue20123 by allowing opUnaryRight to disable post-[inc|dec]rement #12301

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thewilsonator
Copy link
Contributor

@thewilsonator thewilsonator added the Review:Needs Spec PR A PR updating the language specification needs to be submitted to dlang.org label Mar 24, 2021
@dlang-bot
Copy link
Contributor

dlang-bot commented Mar 24, 2021

Thanks for your pull request and interest in making D better, @thewilsonator! 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
20123 normal Impossible to disable post-increment/decrement semantics

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

Comment on lines +444 to +446
void errorRet()
{
result = ErrorExp.get();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know there is a method somewhere that does exactly this but I can't remember whats its called.

auto fdr = search_function(ad, Id.opUnaryRight);
if (!fdr)
return visit(cast(BinExp) pe);

Copy link
Member

Choose a reason for hiding this comment

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

from here on the function always returns an error. The control flow can be simplified to make that clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

from here on the function always returns an error

correct.

The control flow can be simplified to make that clear.

How?

/* TEST_OUTPUT:
---
fail_compilation/issue20123.d(39): Error: can only `@disable` opUnaryRight
fail_compilation/issue20123.d(39): Error: can only `@disable` opUnaryRight
Copy link
Contributor

Choose a reason for hiding this comment

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

A doesn't have disabled methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as in the only thing you are allowed to do with opUnaryRight is to @disable it. Perhaps that should be worded better.

Copy link
Contributor

Choose a reason for hiding this comment

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

as in the only thing you are allowed to do with opUnaryRight is to @disable it.

For the moment. Give it some days and people in the forums will demand it to be usable properly.

fail_compilation/issue20123.d(39): Error: can only `@disable` opUnaryRight
fail_compilation/issue20123.d(39): Error: can only `@disable` opUnaryRight
fail_compilation/issue20123.d(40): Error: cannot be used because it is annotated with `@disable`
fail_compilation/issue20123.d(40): Error: cannot be used because it is annotated with `@disable`
Copy link
Contributor

Choose a reason for hiding this comment

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

WHAT cannot be used?
Also maybe add an errorSupplemental pointing to the disabled operator overload?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oof. That needs work.

Copy link
Contributor

@12345swordy 12345swordy left a comment

Choose a reason for hiding this comment

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

See comments

@RazvanN7
Copy link
Contributor

RazvanN7 commented Apr 8, 2021

@thewilsonator What is the status of this?

@thewilsonator
Copy link
Contributor Author

waiting on input from @TurkeyMan

@RazvanN7
Copy link
Contributor

ping @TurkeyMan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs rebase Review:Needs Rebase Review:Needs Spec PR A PR updating the language specification needs to be submitted to dlang.org Review:stalled Severity:Bug Fix stalled
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants