Describe the bug
It is not casting properly by using or { '' } after array indexing
Reproduction Steps
struct Struct {
f1 string
f2 int
f3 bool
f4 f64
}
struct StructWithFieldsOfOptionalArray {
f1 []? string
f2 []? int
f3 []? bool
f4 []? f64
}
fn main () {
v1 := StructWithFieldsOfOptionalArray{
f1 : [? string ('a' ), 'b' ]
f2 : [? int (1 ), 2 ]
f3 : [? bool (true ), false ]
f4 : [? f64 (1.1 ), 2.2 ]
}
v2 := Struct{
f1 : v1 .f1 [0 ] or { '' }
f2 : v1 .f2 [0 ] or { 0 }
f3 : v1 .f3 [0 ] or { false }
f4 : v1 .f4 [0 ] or { 0.0 }
}
assert v2 .f1 == 'a'
assert v2 .f2 == 1
assert v2 .f3 == true
assert v2 .f4 == 1.1
}
Expected Behavior
assert pass
Current Behavior
examples/hexagonal/src/infrastructure/repositories/pg_user_repository.v:23:3: error: cannot assign an Option value to a non-option struct field
21 | }
22 | v2 := Struct{
23 | f1: v1.f1[0] or { ' ' }
| ~ ~~~~~~~~~~~~~~~~~~~~~
24 | f2: v1.f2[0] or { 0 }
25 | f3: v1.f3[0] or { false }
examples/hexagonal/src/infrastructure/repositories/pg_user_repository.v:24:3: error: cannot assign an Option value to a non-option struct field
22 | v2 := Struct{
23 | f1: v1.f1[0] or { ' ' }
24 | f2: v1.f2[0] or { 0 }
| ~ ~~~~~~~~~~~~~~~~~~~~
25 | f3: v1.f3[0] or { false }
26 | f4: v1.f4[0] or { 0.0 }
examples/hexagonal/src/infrastructure/repositories/pg_user_repository.v:25:3: error: cannot assign an Option value to a non-option struct field
23 | f1: v1.f1[0] or { ' ' }
24 | f2: v1.f2[0] or { 0 }
25 | f3: v1.f3[0] or { false }
| ~ ~~~~~~~~~~~~~~~~~~~~~~~~
26 | f4: v1.f4[0] or { 0.0 }
27 | }
examples/hexagonal/src/infrastructure/repositories/pg_user_repository.v:26:3: error: cannot assign an Option value to a non-option struct field
24 | f2: v1.f2[0] or { 0 }
25 | f3: v1.f3[0] or { false }
26 | f4: v1.f4[0] or { 0.0 }
| ~ ~~~~~~~~~~~~~~~~~~~~~~
27 | }
28 | assert v2.f1 == ' a'
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.12 0800feb
Environment details (OS name and version, etc.)
Linux
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
Describe the bug
It is not casting properly by using
or { '' }after array indexingReproduction Steps
Expected Behavior
assert pass
Current Behavior
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.12 0800feb
Environment details (OS name and version, etc.)
Linux
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.