Skip to content

Commit

Permalink
Fix crash when last expr is a Fun(..)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebresafegaga committed Dec 23, 2022
1 parent bb9e79e commit ce765ce
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lsp/nls/src/linearization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ impl<'a> Linearizer for AnalysisHost<'a> {
};
match field.kind {
TermKind::RecordField { ref mut value, .. } => {
pos = field.pos;
*value = ValueState::Known(ItemId {
file_id: self.file,
index: id_gen.get() + usage_offset,
Expand Down Expand Up @@ -403,6 +404,7 @@ impl<'a> Linearizer for AnalysisHost<'a> {
final_term_pos(body)
}
Term::Op1(UnaryOp::StaticAccess(field), _) => &field.pos,
Term::Fun(ident, _) | Term::FunPattern(Some(ident), ..) => &ident.pos,
_ => pos,
}
}
Expand All @@ -415,7 +417,11 @@ impl<'a> Linearizer for AnalysisHost<'a> {
let term = lin.cache.get(*file).unwrap();
let position = final_term_pos(&term);
let locator = (*file, position.unwrap().start);
let term_id = linearization.item_at(&locator).unwrap().id;

let Some(term_id) = linearization.item_at(&locator) else {
return
};
let term_id = term_id.id;

lin.push(LinearizationItem {
env: self.env.clone(),
Expand Down

0 comments on commit ce765ce

Please sign in to comment.