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

parser, checker: fix const var below at struct fixed array fields(fix#19593) #19893

Merged
merged 2 commits into from
Nov 16, 2023

Conversation

shove70
Copy link
Contributor

@shove70 shove70 commented Nov 16, 2023

  1. Fixed Can't use const value for fixed array that is a struct's field if const was declared below struct declaration #19593
  2. Add tests.
struct Test {
	posts [max_posts_count]int
}

const max_posts_count = 5

t := Test{}
println(t)

outputs:

[0, 0, 0, 0, 0]

Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

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

Excellent work.

@spytheman spytheman merged commit 4dff383 into vlang:master Nov 16, 2023
54 checks passed
@shove70 shove70 deleted the fixed_array_const_size branch November 16, 2023 06:23
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.

Can't use const value for fixed array that is a struct's field if const was declared below struct declaration
2 participants