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 #24369 #24370

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open

Fixes #24369 #24370

wants to merge 2 commits into from

Conversation

saemideluxe
Copy link

@saemideluxe saemideluxe commented Oct 27, 2024

Hope this fixes #24369, happy for any feedback on the PR.

@@ -2969,5 +2969,4 @@ proc arrayWith*[T](y: T, size: static int): array[size, T] {.raises: [].} =
when nimvm:
result[i] = y
else:
# TODO: fixme it should be `=dup`
result[i] = y
result[i] = `=dup`(y)
Copy link
Member

Choose a reason for hiding this comment

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

Problem is that the comment is wrong and the explicit =dup should not be necessary.

Copy link
Author

Choose a reason for hiding this comment

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

So, if I understand correctly, the current implementation of arrayWith is correct as it has been so far (as we actually will copy y, but in the example type we forbid copying values, so semantics seem correct to me). But maybe there would need to be an alternative implementation of this function to implement array initialization using the default proc to generate the default value instead of passing in a default value?

If my assumptions are correct, I guess I would need to make changes in the defaultNodeField proc. Somewhere around here:

result = semExpr(c, newTree(nkCall, newSymNode(getSysSym(c.graph, a.info, "arrayWith"), a.info),
correct?

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.

Array field that has array-element type with copy-protector and default value set on a field will yield error
2 participants