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

feat(sdk): let MutArray.push() accept variadic arguments of the same … #5114

Merged
merged 3 commits into from
Dec 5, 2023

Conversation

graylime
Copy link
Contributor

@graylime graylime commented Dec 4, 2023

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

  • Title matches Winglang's style guide
  • 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.

monadabot and others added 2 commits December 4, 2023 06:18
Signed-off-by: monada-bot[bot] <monabot@monada.co>
@monadabot monadabot added the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Dec 4, 2023
Copy link
Contributor

@Chriscbr Chriscbr left a comment

Choose a reason for hiding this comment

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

LGTM

libs/wingc/src/type_check.rs Show resolved Hide resolved
@Chriscbr Chriscbr removed the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Dec 5, 2023
Copy link
Contributor

mergify bot commented Dec 5, 2023

Thanks for contributing, @autow0rk! This PR will now be added to the merge queue, or immediately merged if main is up-to-date with main and the queue is empty.

mergify bot added a commit that referenced this pull request Dec 5, 2023
@mergify mergify bot merged commit bd2ee19 into winglang:main Dec 5, 2023
15 checks passed
@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.51.11.

@staycoolcall911
Copy link
Contributor

Hey @autow0rk, just wanted to let you know it looks like this didn't fix #4836

mergify bot pushed a commit that referenced this pull request Dec 11, 2023
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)*.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't push more than one element to an array in a single call to MutArray.push() method
4 participants