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 13507 - std.range.enumerate with BigInt indexes too #6496
fix Issue 13507 - std.range.enumerate with BigInt indexes too #6496
Conversation
Thanks for your pull request and interest in making D better, @Voultapher! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
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
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + phobos#6496" |
f87dd96
to
02e3f36
Compare
02e3f36
to
e6c5848
Compare
@@ -10114,6 +10115,26 @@ pure @safe unittest | |||
}} | |||
} | |||
|
|||
/// enumerate works with BigInt | |||
@system pure unittest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With three /// this will be part of the documentation (hence the CI failure).
I recommend doing the following:
- have a small public, minimal test
- use a more complex private test or tests
static assert(is(typeof(enumerated.front.index) == BigInt)); | ||
assert(offsetEnumerated.equal(subset.zip(subset))); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a test with very big numbers?
{ | ||
auto subset = values[cast(size_t) i .. $]; | ||
auto offsetEnumerated = subset.enumerate!BigInt(i); | ||
static assert(is(typeof(enumerated.front.index) == BigInt)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not influenced by the loop (and already tested before)
Maybe you meant offsetEnumerated?
|
||
auto enumerated = values.enumerate!BigInt(); | ||
static assert(is(typeof(enumerated.front.index) == BigInt)); | ||
assert(enumerated.equal(values[].zip(values))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for the slicing here.
As discussed with @wilzbach, the feature could be implemented, in a minimal working way. Yet, trying to test it revealed ergonomic issues with other library components. For example, getting an enumerate range to a point where const auto upperBound = BigInt("1_000_000_000_000_000_000_000");
auto range = iota(upperBound).enumerate!BigInt;
range.popFrontN(upperBound - 10); For this to work, |
I've got an idea for how to fix |
If you want to change |
This was tagged as a Bootcamp issue, now it has evolved into a wider design discussion. I'd be glad if someone more experienced with the codebase could take over. |
This has not seen any progress in years so I'm closing it. |
Seems to work with modified existing unit test. Didn't find a good way to test enumerate range with a
BigInt
worthy size.