vfmt: do not error on `field [fsize]Type`, where `fsize` is from another .v file
parent
7c0f8f7644
commit
e512caf8f5
|
@ -12,3 +12,17 @@ fn foo() [1]f32 {
|
|||
fn main() {
|
||||
_ := [5]string{init: 'abc'}
|
||||
}
|
||||
|
||||
// NB: secret_key_size is missing here on purpose
|
||||
// vfmt should leave it as is, assuming it is comming
|
||||
// from another .v file
|
||||
|
||||
struct VerifyKey {
|
||||
public_key [public_key_size]byte
|
||||
}
|
||||
|
||||
struct SigningKey {
|
||||
secret_key [secret_key_size]byte
|
||||
pub:
|
||||
verify_key VerifyKey
|
||||
}
|
||||
|
|
|
@ -26,7 +26,14 @@ pub fn (mut p Parser) parse_array_type() ast.Type {
|
|||
size_expr.pos)
|
||||
}
|
||||
} else {
|
||||
p.error_with_pos('non-constant array bound `$size_expr.name`', size_expr.pos)
|
||||
if p.pref.is_fmt {
|
||||
// for vfmt purposes, pretend the constant does exist, it may have
|
||||
// been defined in another .v file:
|
||||
fixed_size = 1
|
||||
} else {
|
||||
p.error_with_pos('non-constant array bound `$size_expr.name`',
|
||||
size_expr.pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue