modularml / mojo

The Mojo Programming Language
https://docs.modular.com/mojo/manual/
Other
23.38k stars 2.6k forks source link

Mojo Language Server reports crash on empty file. #3826

Open RichardCoppin opened 4 days ago

RichardCoppin commented 4 days ago

Issue Description

It would seem that the Language Server is unable to deal with empty .mojo files. This is particularly an issue with __init__.mojo files which are often meant to be empty.

This creates a false positive as the packages are highlighted as containing errors, which in fact do not: image

This is the error message received when opening an empty .mojo file:

A crash happened in the Mojo Language Server when processing this document. The Language Server will try to reprocess this document once it is edited again. Please report this issue in https://github.com/modularml/mojo/issues along with all the relevant source codes with their current contents.

Steps to reproduce:

Create an empty __init__.mojo file. Open said mojo file. Observe error: image

Request:

The LSP should be able to deal with empty .mojo files and not report a crash.

Workaround:

Adding a comment or a blank line to the top of the init file removes the error.

walter-erquinigo commented 1 day ago

Thank you for reporting this! I'll look into it soon.