Completion stack overflow with module corner case
In completion.ml
, in this function:
let rec get_module_defs : Scopes.Types.mod_case -> CompletionItem.t list option
= function
| Def defs -> Some (module_defs_to_completion_items defs)
| Alias (_alias, resolved) ->
Option.bind resolved ~f:(fun resolved ->
List.find_map get_scope_info.definitions ~f:(function
| Variable _ | Type _ -> None
| Module m ->
if String.(m.name = resolved) then get_module_defs m.mod_case else None))
It's possible we'll get a stack overflow from List.find_map
, probably due to the recursive call to get_module_defs
. I'm not sure how to reproduce this, but this deserves attention.
Likely we shouldn't compare the name directly with String.(m.name = resolved)
, but rather use UIDs for this.
Acceptance criteria
- Stack overflow is resolved.
- Tests added.