mirror of
https://github.com/vlang/v.git
synced 2025-09-13 09:25:45 -04:00
parser: fix assigning with in another module sumtypes (#19414)
This commit is contained in:
parent
ed42341642
commit
9929e956f0
@ -164,6 +164,7 @@ fn (mut p Parser) array_init(is_option bool) ast.ArrayInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pos := first_pos.extend_with_last_line(last_pos, p.prev_tok.line_nr)
|
pos := first_pos.extend_with_last_line(last_pos, p.prev_tok.line_nr)
|
||||||
|
p.expr_mod = ''
|
||||||
return ast.ArrayInit{
|
return ast.ArrayInit{
|
||||||
is_fixed: is_fixed
|
is_fixed: is_fixed
|
||||||
has_val: has_val
|
has_val: has_val
|
||||||
|
16
vlib/v/tests/assign_with_in_module_sumtype_test.v
Normal file
16
vlib/v/tests/assign_with_in_module_sumtype_test.v
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import aa
|
||||||
|
|
||||||
|
fn test_assign_with_in_module_sumtype() {
|
||||||
|
node := aa.MySumType(aa.S1{})
|
||||||
|
|
||||||
|
cond := node in [aa.S1, aa.S2]
|
||||||
|
mut b := 'b'
|
||||||
|
mut c := 'c'
|
||||||
|
|
||||||
|
if cond {
|
||||||
|
println('${cond} --- ${b} --- ${c}')
|
||||||
|
assert '${cond} --- ${b} --- ${c}' == 'true --- b --- c'
|
||||||
|
} else {
|
||||||
|
assert false
|
||||||
|
}
|
||||||
|
}
|
7
vlib/v/tests/modules/aa/aa.v
Normal file
7
vlib/v/tests/modules/aa/aa.v
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module aa
|
||||||
|
|
||||||
|
pub type MySumType = S1 | S2
|
||||||
|
|
||||||
|
pub struct S1 {}
|
||||||
|
|
||||||
|
pub struct S2 {}
|
Loading…
x
Reference in New Issue
Block a user