parser: fix interface method declaration with fixed array return type (fix #25137) (#25145)

This commit is contained in:
Felipe Pena 2025-08-20 14:52:10 -03:00 committed by GitHub
parent b3073b96b5
commit 98ca0f075e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 0 deletions

View file

@ -799,7 +799,10 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl {
} }
if p.tok.kind.is_start_of_type() && p.tok.line_nr == line_nr { if p.tok.kind.is_start_of_type() && p.tok.line_nr == line_nr {
method.return_type_pos = p.tok.pos() method.return_type_pos = p.tok.pos()
last_inside_return := p.inside_fn_return
p.inside_fn_return = true
method.return_type = p.parse_type() method.return_type = p.parse_type()
p.inside_fn_return = last_inside_return
method.return_type_pos = method.return_type_pos.extend(p.tok.pos()) method.return_type_pos = method.return_type_pos.extend(p.tok.pos())
method.pos = method.pos.extend(method.return_type_pos) method.pos = method.pos.extend(method.return_type_pos)
} }

View file

@ -0,0 +1,20 @@
interface IValue {
value() [2]int
}
struct Speed {
data [2]int
}
fn (s Speed) value() [2]int {
return s.data
}
fn get_value(v IValue) [2]int {
return v.value()
}
fn test_main() {
s := Speed{[35, 36]!}
assert get_value(s) == [35, 36]!
}