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

fixes #22926; Different type inferred when setting a default value fo… #22955

Closed
wants to merge 3 commits into from

Conversation

ringabout
Copy link
Member

…r an array field

fixes #22926

@ringabout ringabout marked this pull request as draft November 17, 2023 13:59
because of global errors
@ringabout ringabout marked this pull request as ready for review November 17, 2023 14:06
@@ -241,6 +241,12 @@ proc fitDefaultNode(c: PContext, n: PNode): PType =
if n[^2].kind != nkEmpty:
if expectedType != nil and oldType != expectedType:
n[^1] = fitNodeConsiderViewType(c, expectedType, n[^1], n[^1].info)
annotateType(n[^1], expectedType, c.config) # infer types for default fields value
Copy link
Member

Choose a reason for hiding this comment

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

We don't do this anywhere else in the compiler.

Copy link
Member Author

@ringabout ringabout Nov 28, 2023

Choose a reason for hiding this comment

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

Well, changeType works as well. Could we use that here? Because semConstExpr didn't infer the type from expectedType.

Copy link
Member

Choose a reason for hiding this comment

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

changeType would be better, yes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! On it

@ringabout
Copy link
Member Author

Succeeded by #22999

@ringabout ringabout closed this Nov 28, 2023
@ringabout ringabout deleted the ringabout-patch-6 branch November 28, 2023 14:00
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.

Different type inferred when setting a default value for an array field
2 participants