mojo icon indicating copy to clipboard operation
mojo copied to clipboard

[BUG] Field of struct's own type consistently crashes the language extension for VS Code (both stable & nightly)

Open siitron opened this issue 10 months ago • 1 comments

Bug description

Writing a struct with a field of its own type in VS Code will crash the language extension (stable/nightly), instead of detecting the problem. The extension(s) crashes and you get notified with:

The Mojo Language Client server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

The extension(s) cannot be restarted until such fields no longer exist.

This could potentionally lead to confusion if you have other types that start with "Self" or the struct is a prefix of another type. E.g.:

struct AB:
    ...
struct Selfish:
    ...
struct A:
    var ab: AB  # Before the 'B' is typed, the extension crashes.
    var s:  Selfish  # For this field the extension would crash before 'ish' has been typed.

Steps to reproduce

The extension(s) will crash simply by typing out either of the following fields:

struct A:
    var a: A
    var b: Self

System information

- OS: Debian (WSL)
- Mojo version: mojo 2024.4.117 (8f6529b0)
- Modular CLI version: modular 0.6.0 (04c05243)

siitron avatar Apr 05 '24 14:04 siitron

Thanks for reporting! Looks like an issue with mojo's handling of self-referential types. This is an issue with the mojo parser in general (the LSP is just a great fuzzer for parser crashes)

River707 avatar Apr 08 '24 17:04 River707