E4089#
Tuple has no field with the given index.
In MoonBit, one can access the element in a tuple using index accessor, like
tuple.0
, tuple.1
, and so on. The index starts with 0, and the compiler
will emit this error if you try to access an element that does not exist in the
tuple, for example, accessing the third element (tuple.2
) in a tuple with only
two elements.
错误示例#
fn main {
let tuple = (1, 2)
println(tuple.2)
}
建议#
To fix this error, you need to access the element within the tuple that exists.
fn main {
let tuple = (1, 2)
println(tuple.1)
}