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

checker: add error for field [$d('x', 2)]int = [1, 2]! #21741

Conversation

larpon
Copy link
Contributor

@larpon larpon commented Jun 26, 2024

Add this:

vlib/v/checker/tests/struct_field_fixed_size_init_with_d_as_size_err.vv:3:31: error: cannot initialize a fixed size array field that uses `$d()` as size quantifier since the size may change via -d
    1 | struct Gin {
    2 | mut:
    3 |     juice [$d('amount', 4)]int = [1, 2, 3, 4]!
      |                                  ~~~~~~~~~~~~~
    4 | }
    5 |

for this code:

struct Gin {
mut:
	juice [$d('amount', 4)]int = [1, 2, 3, 4]!
}

fn main() {}

@spytheman spytheman merged commit d67f4d0 into vlang:master Jun 27, 2024
76 checks passed
@larpon larpon deleted the checker/add-error-for-fixed-size-struct-field-d-as-size branch June 27, 2024 10:17
raw-bin pushed a commit to raw-bin/v that referenced this pull request Jul 2, 2024
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.

2 participants