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

Fix orelse type resolution #1896

Merged
merged 6 commits into from
May 20, 2024
Merged

Fix orelse type resolution #1896

merged 6 commits into from
May 20, 2024

Conversation

Sekky61
Copy link
Contributor

@Sekky61 Sekky61 commented May 16, 2024

Fixes #1330

See the added tests, they make it pretty clear. One example:

const foo: ?i32 = 5;
const b<cursor>ar = foo orelse foo;

outputs

?i32

This is my first PR so I'd be happy for any pointers.

@Sekky61 Sekky61 marked this pull request as draft May 16, 2024 11:27
@Sekky61
Copy link
Contributor Author

Sekky61 commented May 16, 2024

I have just noticed #1728, so I will work on that before opening the PR.

@Sekky61
Copy link
Contributor Author

Sekky61 commented May 17, 2024

In the end I opted for a simpler solution. I noticed orelse has basically the same problem as if and others -- the unification of the types from both child nodes / branches.

I looked into resolvePeerTypes and how the Either type is used but that may be a discussion for another issue.

@Sekky61 Sekky61 marked this pull request as ready for review May 17, 2024 20:56
src/analysis.zig Outdated Show resolved Hide resolved
src/analysis.zig Outdated Show resolved Hide resolved
@Techatrix Techatrix merged commit c9ba2c9 into zigtools:master May 20, 2024
3 checks passed
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.

Wrong variable type info when orelse assigns variable with an optional type
2 participants