rokucommunity / brighterscript

A superset of Roku's BrightScript language
MIT License
162 stars 46 forks source link

parsing issue: Array literals in function params cause compile fail #109

Closed georgejecook closed 3 years ago

georgejecook commented 4 years ago

this bs

if not MU.isArray(args)
 logError(["apply expects an array of args"])
end if

compiles to:

    if not MU_isArray(args) then
        log_error([
            "apply expects an array of args"
        ])
        return invalid
    end if

that is NOT legal brs; I just tried, and multiline array literal declaration is for assign only; can't be used inline in function calls.

TwitchBronBron commented 4 years ago

@georgejecook I don't think your statement is correct. I just ran this BrightScript program, and it compiled on-device and ran without issue. I think there might be something else at play here.

sub main()
    DoSomething("anything")
end sub

function DoSomething(args)
    if not MU_isArray(args) then
        log_error([
            "apply expects an array of args"
        ])
        return invalid
    end if
end function

sub log_error(arr)
    for each item in arr
        print item
    end for
end sub

function MU_isArray(args)
    return false
end function
georgejecook commented 3 years ago

closing - old.