DanielGavin / ols

Language server for Odin
MIT License
375 stars 56 forks source link

Crash on shadowing proc name in it's body #403

Open thetarnav opened 3 weeks ago

thetarnav commented 3 weeks ago

There is a bug that crashes the server basically if you shadow declaration names like here:

main :: proc () {
    main := m // completion code will cause crash when typing here
}

the ident has an offset of -1 which causes a bounds check failure

[Trace - 9:11:10 PM] Sending request 'textDocument/completion - (1)'.
[Trace - 9:11:10 PM] Sending request 'textDocument/documentSymbol - (2)'.
[Trace - 9:11:10 PM] Sending request 'textDocument/documentLink - (3)'.
/home/thetarnav/ols/src/common/position.odin(157:31) Invalid slice indices -1:382 is out of range 0..<382

happens on both master and rename branches

Screenshot from 2024-06-12 21-27-36

Interestingly the offset < 0 check is not hit, so it's reassigned to -1 after second go_backwards_to_endline call.

DanielGavin commented 2 weeks ago

Doesn't happen to me on the rename branch.

thetarnav commented 2 weeks ago

Just pulled and rebuilt and the same thing.

Screencast from 14.06.2024 18:34:40.webm

DanielGavin commented 2 weeks ago

I see it now. I was running on the release ols without bounds check. I guess you are running on the debug build?

DanielGavin commented 2 weeks ago

Should be fixed on rename.

thetarnav commented 2 weeks ago

I'm just doing ./build.sh. it doesn't disable bounds checks. Only ./build.bat does. And it doesn't happen anymore :+1: