DanielGavin / ols

Language server for Odin
MIT License
417 stars 62 forks source link

ols not working with new feature from odin with #reverse #243

Closed mahSource closed 12 months ago

mahSource commented 1 year ago
  1. The first line of #reverse code with the do single statement will work, but wreaks havoc on the ols if you adjust code format after a save. It generates numerous errors.
  2. Errors include from no package declaration at the beginning of the file (and there is one), to you cannot use a block statement in file scope for block statements after the special directive. It will also signal 'expected a statement, got } error (but there is a statement.....)
  3. The second line of code where the same fmt.println() is put in a block works and produces no error messages.
    array2 := [?]int{1, 2, 3, 4, 5}
    #reverse for x in array2 do fmt.println(x) // this generates many, many ols errors
    #reverse for x in array2 {
        fmt.println(x)
    } // this version works perfectly

    This took a while to isolate in a large file, I had to progressively comment out lines until it was clear only the #reverse statement with do that caused everything.

DanielGavin commented 1 year ago

Looks like a bug in core:odin/parser.

Just running

main :: proc() {
    array2 := [?]int{1, 2, 3, 4, 5}
    #reverse for x in array2 do fmt.println(x) // this generates many, many ols errors
}

Gives _test/test.odin(11:1): expected '}', got 'EOF'

DanielGavin commented 1 year ago

Waiting on my PR: https://github.com/odin-lang/Odin/pull/2785

DanielGavin commented 12 months ago

Fixed.

mahSource commented 12 months ago

Thanks so much Daniel. Just loaded in the OLS and it works perfectly on my system now with the subject code. Cheers!