-
Notifications
You must be signed in to change notification settings - Fork 83
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 slice stackoverflow in certain scenarios #287
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
@hcanyz - thanks for the contribution! Can you update the changelog and the pubspec version as per https://github.com/dart-lang/.github/blob/main/PULL_REQUEST_TEMPLATE.md? |
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.
Good fix, thank you.
As @devoncarew said, upping the version in the SDK (just a minor version increment is enough) and adding an entry in CHANGELOG.md saying what that version does (fixes bug in List.slice
and ListSlice.slice
methods), should be enough to make it publishable.
lib/src/list_extensions.dart
Outdated
@@ -241,7 +241,7 @@ extension ListExtensions<E> on List<E> { | |||
ListSlice<E> slice(int start, [int? end]) { | |||
end = RangeError.checkValidRange(start, end, length); | |||
var self = this; | |||
if (self is ListSlice) return self.slice(start, end); | |||
if (self is ListSlice<E>) return self.slice(start, end); |
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 a constant foot-gun. I'll add another notch to the issue suggesting we promote to ListSlice<E>
here.)
lib/src/list_extensions.dart
Outdated
@@ -404,7 +404,7 @@ class ListSlice<E> extends ListBase<E> { | |||
/// ``` | |||
ListSlice<E> slice(int start, [int? end]) { | |||
end = RangeError.checkValidRange(start, end, length); | |||
return ListSlice._(_initialSize, source, start + start, end - start); | |||
return ListSlice._(_initialSize, source, this.start + start, end - start); |
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 was just bad. Sorry 😢
@hcanyz - thanks for the follow-up; can you also update the pubspec version to |
CHANGELOG.md
Outdated
@@ -1,3 +1,7 @@ | |||
## 1.17.3 | |||
|
|||
* Fixes bug in List.slice and ListSlice.slice methods. |
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.
* Fixes bug in List.slice and ListSlice.slice methods. | |
* Fixes a bug in the `List.slice` and `ListSlice.slice` methods. |
1.18.0-wip has been committed on the master branch, and I don't know how to proceed with submitting this PR. Use 1.18.1 ?, or you guys come and commit this change : ) . |
fix #286