Skip to content

Commit 98ca0f0

Browse files
authored
parser: fix interface method declaration with fixed array return type (fix #25137) (#25145)
1 parent b3073b9 commit 98ca0f0

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

vlib/v/parser/struct.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,10 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl {
799799
}
800800
if p.tok.kind.is_start_of_type() && p.tok.line_nr == line_nr {
801801
method.return_type_pos = p.tok.pos()
802+
last_inside_return := p.inside_fn_return
803+
p.inside_fn_return = true
802804
method.return_type = p.parse_type()
805+
p.inside_fn_return = last_inside_return
803806
method.return_type_pos = method.return_type_pos.extend(p.tok.pos())
804807
method.pos = method.pos.extend(method.return_type_pos)
805808
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
interface IValue {
2+
value() [2]int
3+
}
4+
5+
struct Speed {
6+
data [2]int
7+
}
8+
9+
fn (s Speed) value() [2]int {
10+
return s.data
11+
}
12+
13+
fn get_value(v IValue) [2]int {
14+
return v.value()
15+
}
16+
17+
fn test_main() {
18+
s := Speed{[35, 36]!}
19+
assert get_value(s) == [35, 36]!
20+
}

0 commit comments

Comments
 (0)