Skip to content

Commit 865da8a

Browse files
authored
fix(lsp): Prevent crash on types not included from other modules (#2137)
1 parent a4d9c61 commit 865da8a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

compiler/src/typed/env.re

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,12 +2481,11 @@ let rec get_type_path = type_expr => {
24812481
let get_type_definition_loc = (type_expr, env) => {
24822482
switch (get_type_path(type_expr)) {
24832483
| Some(path) =>
2484-
let decl = find_type(path, env);
2485-
if (decl.type_loc == Location.dummy_loc) {
2486-
None;
2487-
} else {
2488-
Some(decl.type_loc);
2489-
};
2484+
switch (find_type(path, env)) {
2485+
| exception Not_found => None
2486+
| {type_loc} when type_loc == Location.dummy_loc => None
2487+
| {type_loc} => Some(type_loc)
2488+
}
24902489
| _ => None
24912490
};
24922491
};

0 commit comments

Comments
 (0)