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

Assigning Json value to a struct's Array field #6448

Closed
eladcon opened this issue May 9, 2024 · 1 comment · Fixed by #6496
Closed

Assigning Json value to a struct's Array field #6448

eladcon opened this issue May 9, 2024 · 1 comment · Fixed by #6496
Assignees
Labels
🐛 bug Something isn't working 🛠️ compiler Compiler

Comments

@eladcon
Copy link
Collaborator

eladcon commented May 9, 2024

I tried this:

struct A {
  x: Array<str>;
}

let a = A{x: {p:"4"}};
log(a.x[0]);

This happened:

It doesn't throw a compilation error

Error: Index is a number but collection is not an array or string

I expected this:

No response

Is there a workaround?

No response

Anything else?

No response

Wing Version

No response

Node.js Version

No response

Platform(s)

No response

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
@eladcon eladcon added the 🐛 bug Something isn't working label May 9, 2024
@Chriscbr Chriscbr added this to the Winglang Stable Release milestone May 9, 2024
@yoav-steinberg yoav-steinberg self-assigned this May 16, 2024
@mergify mergify bot closed this as completed in #6496 May 16, 2024
mergify bot pushed a commit that referenced this issue May 16, 2024
#6496)

fixes #6448

stractural Json object assignment can only be assigned to wing maps or structs (not arrays).

Also fixes the diagnostic hint about using `fromJson` for dynamic json conversion to be shown only for actual dynamic jsons.

## 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)*.
@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.73.48.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🛠️ compiler Compiler
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants