rokucommunity / brighterscript

A superset of Roku's BrightScript language
MIT License
153 stars 47 forks source link

Incorrectly reporting errors #548

Open John-Whitehead opened 4 years ago

John-Whitehead commented 4 years ago

Operating System: Fedora 30 VS Code: 1.44.0 BRS Extension: 2.1.2

I am getting red squiggle lines under code which is actually correct. It was on a huge non-SG screensaver main.brs, but I can reproduce it at will with the following steps. $ mkdir test $ cd test $ code .

Open a new Untitled file, and then type or paste the following code:

Function RunScreenSaver( params As Object ) As Object
     main()
End Function

sub main()
    print "Entering main()..."
    m.screen  = CreateObject("roScreen")                    ' Required object
    m.port    = CreateObject("roMessagePort")               ' Required object
    di        = CreateObject("roDeviceInfo")                ' For resolution info
    timeStamp = CreateObject("roDateTime")                  ' For elapsed time
    i% = 1

    i% = i% << 3
    i% = i% >> 3

    for j = 1 to 10
        print j
    next j

    for k = 1 to 10
        print k
    end for

end sub

All should look well, until you hit <CTRL-S> and save as main.brs. After writing to disk, the red marks appear, as shown in the attached screenshot below.

There was a red squiggle under the "j" in "next j" but I upgraded the version of VS Code and the extension this morning and I can no longer reproduce that.

My screensaver compiles and runs fine even with the squigle marks.

Screenshot from 2020-04-12 09-56-33

TwitchBronBron commented 4 years ago

I'm a little confused about "Then type or paste the following code:". Do you mean open a new untitled file in vscode? image

If so, then the language validation doesn't actually work for those types of files. The file needs to have been saved with a .brs extension. So this all actually makes sense to me.

John-Whitehead commented 4 years ago

You are correct, Bronley. You need to open a new file before pasting the code. I updated my original comment. Yes, the errors do not appear until after the file is saved with a .brs extension and the status line at the bottom changes from "Plain Text" to "Brightscript". So, the thought that it happens sometimes and not others was just a red herring.

chrisdp commented 2 years ago

Update to this issue: image image

TwitchBronBron commented 2 years ago

This is a weird syntax. What's the use case for that? Could you call next <some other variable>? If so, what does it do? In order to support this functionality, I need to know how it functions so the language server can build the AST.