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

Use result location type in unionInit #16484

Open
silversquirl opened this issue Jul 22, 2023 · 0 comments
Open

Use result location type in unionInit #16484

silversquirl opened this issue Jul 22, 2023 · 0 comments
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone

Comments

@silversquirl
Copy link
Contributor

@unionInit could infer its target type from the result location, similar to #5909.

// Old
const foo = @unionInit(MyUnion, "field", value);
// New
const foo: MyUnion = @unionInit("field", value);

// Old
const foo: MyStruct = .{ .my_field = @unionInit(MyUnion, "field", value) };
// New
const foo: MyStruct = .{ .my_field = @unionInit("field", value) };

// Old
myFunc(@unionInit(MyUnion, "field", value));
// New
myFunc(@unionInit("field", value));
@andrewrk andrewrk added the proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. label Jul 22, 2023
@andrewrk andrewrk added this to the 0.12.0 milestone Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Projects
None yet
Development

No branches or pull requests

2 participants