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

Issue 22383 is solved so now can use noreturn #8283

Closed
wants to merge 2 commits into from

Conversation

dukc
Copy link
Contributor

@dukc dukc commented Oct 15, 2021

However, this is still draft because the compiler ICEd when testing

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @dukc! 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
22383 normal Array of bottom types not recognized as a range

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 + phobos#8283"

@dukc
Copy link
Contributor Author

dukc commented Oct 15, 2021

Cause for ICE: https://issues.dlang.org/show_bug.cgi?id=22390

@pbackus
Copy link
Contributor

pbackus commented Oct 15, 2021

What's the motivation for this? Does this enable any specific usage that the previous version didn't? If so, the PR should include a unit test for that usage.

@MoonlightSentinel
Copy link
Contributor

MoonlightSentinel commented Oct 15, 2021

Some (possible) minor advantages(?):

  1. Removes a redundant custom type
  2. only() can be used to initialize other types that accept a slice
  3. front and friends become noreturn as well, diagnosing some misuse (but that's really hypothetical)

@pbackus
Copy link
Contributor

pbackus commented Oct 15, 2021

only() can be used to initialize other types that accept a slice

Isn't the entire point of using Voldemort types to prevent users from relying on the concrete types of ranges? The only guarantee only currently makes about its return value is that it is "A RandomAccessRange" [1]. If someone wants to initialize a slice with only(), they should be using only().array.

Regardless, if this is intended to be a supported use-case, there should be a unit test for it.

[1] https://dlang.org/phobos/std_range.html#only

@MoonlightSentinel
Copy link
Contributor

True, relying on that behavior would be problematic when only is used in variadic templates

@dukc
Copy link
Contributor Author

dukc commented Oct 15, 2021

only() should not be relied on being an array, that's an implementation detail. It recently was a private type, i just recently replaced it with a slice in name of simplification. Perhaps unwise, considering that a slice is also bigger than an empty struct. Pr was #8269 - shall we revert?

But there is one useful property with noreturn elements: they will convert to anything. This enables stuff like float[] arr = chain(only(1,2,3), only(1.1, 2.2, 3.3), only()).array;. I'll add an unit test but not today. The ICE needs to be solved before testing anyway.

@pbackus
Copy link
Contributor

pbackus commented Oct 15, 2021

I'd say it's fine to use a noreturn[] as an implementation detail if it's the simplest way to support the desired use-cases, but the return type should still be auto and documented only as "a random-access range."

@RazvanN7
Copy link
Collaborator

@dukc I am going to close this as the implementation of noreturn is still half baked. We can come back to this later.

@RazvanN7 RazvanN7 closed this Jan 25, 2022
@dukc
Copy link
Contributor Author

dukc commented Jan 25, 2022

@dukc I am going to close this as the implementation of noreturn is still half baked. We can come back to this later.

Okay

@pbackus
Copy link
Contributor

pbackus commented Jan 25, 2022

Seems strange to close this outright. Why not label as "blocked" if it's only being held back by compiler issues?

@RazvanN7
Copy link
Collaborator

@pbackus I did not see the point in having this PR in the queue while noreturn is still semi-implemented. However, indeed, we can keep it open and label it as blocked.

@RazvanN7
Copy link
Collaborator

Issue 22390 has been fixed. Let's give this another spin.

@dukc dukc marked this pull request as ready for review July 20, 2022 18:16
@dukc
Copy link
Contributor Author

dukc commented Sep 10, 2022

Tried to get this to compile. You guessed it: 1-3 more ICEs dug up from this rabbit hole. Here: https://issues.dlang.org/show_bug.cgi?id=23331

@dukc
Copy link
Contributor Author

dukc commented Sep 24, 2022

I close this for now. This PR has resulted in three different bug reports already, two of them ICEs. When this PR compiles and passes the tests after enought ICEs are solved, it's still likely that some client code that happens to use empty only() in a different way than our test will ICE after a compiler update.

@dukc dukc closed this Sep 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants