-
Notifications
You must be signed in to change notification settings - Fork 199
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
Can't push more than one element to an array in a single call to MutArray.push() method #4836
Comments
Marking this as a good first issue - I think might just require changing the signature of Before:
After:
|
#5114) Closes #4836 For the MutArray container type, the .push() method should take a variadic type. This is implemented in the type_check.rs file, by substituting a generic variadic argument type (T1) with the container's element type when typechecking the function arguments. ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [ ] ~~Tests added (always)~~ Snapshots for MutArray.push() were updated, not sure if new test cases need to be added for this - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
Congrats! 🚀 This was released in Wing 0.51.11. |
Looks like this wasn't fixed by #5114 |
Thanks for the heads up and sorry for the confusion @staycoolcall911 , I forgot to attach the updated array.ts file definition + the updated snapshots. Those are now linked in this new PR: #5169 |
Fixes issue in #5114 and closes #4836 Attach updated array.ts file (has updated definition for .push() on MutArray to support variadic arguments) and update snapshots Example Input: let myList: MutArray<str> = MutArray<str> ["element1"]; myList.push("element2", "element3"); Example Output: const myList = ["element1"]; ((obj, args) => { obj.push(...args); })(myList, ["element2", "element3"]); ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
Congrats! 🚀 This was released in Wing 0.51.17. |
I tried this:
This happened:
push method supports only one value.
I expected this:
both "element2" and "element3" to be added to the end of my array in the order of their appearance in the push method arguments list.
Is there a workaround?
Component
Language Design
Wing Version
latest
Node.js Version
No response
Platform(s)
MacOS
Anything else?
No response
Community Notes
The text was updated successfully, but these errors were encountered: