rokucommunity / bslint

A linter for BrightScript and BrighterScript.
MIT License
28 stars 15 forks source link

Narrow variables assignments when testing for `invalid` #12

Closed elsassph closed 4 years ago

elsassph commented 4 years ago

Fixes #9

sub ok8()
    a = Rnd(10)
    if a > 5
        b = a
    end if
    if b <> invalid ' narrow variable as safe
        print "b"; b
    end if
end sub

sub ok9()
    a = Rnd(10)
    if a > 5
        b = a
    end if
    if b = invalid ' narrowed
        print "b"; b
    end if
end sub

sub ok10()
    a = Rnd(10)
    if a > 5
        b = a
    end if
    if b = invalid ' narrowed exit
        return
    end if
    print "b"; b
end sub
TwitchBronBron commented 4 years ago

Nice work. I review (after the fact) and nothing sticks out.