Closed elogir closed 3 months ago
Splitting the return expression into several statements can be used as a workaround:
module main
import encoding.xml
fn main() {
get_text := fn (node xml.XMLNode, tag string) !string {
elements := node.get_elements_by_tag(tag)[0]!
children := elements.children[0]!
return children.str()
}
dump(get_text)
}
A simpler (less dependencies, and easier to isolate) reproduction of the same problem is:
struct Element {
children []int
}
fn f() []Element {
return [Element{
children: [1, 2, 3]
}]
}
a := f()[0]!.children[0]!.str()
dump(a)
V doctor:
What did you do?
v -g -o vdbg cmd/v && vdbg bug.v
What did you expect to see?
compiles
What did you see instead?