Fix panic in tuple fields

This commit is contained in:
Aleksey Kladov 2020-01-07 14:49:42 +01:00
parent 8f1792fde2
commit 4d66f5d7d2

View file

@ -93,7 +93,10 @@ impl AsName for ast::FieldKind {
fn as_name(&self) -> Name {
match self {
ast::FieldKind::Name(nr) => nr.as_name(),
ast::FieldKind::Index(idx) => Name::new_tuple_field(idx.text().parse().unwrap()),
ast::FieldKind::Index(idx) => {
let idx = idx.text().parse::<usize>().unwrap_or(0);
Name::new_tuple_field(idx)
}
}
}
}