rokucommunity / brighterscript

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

Incorrect `m` for AA function inside class #1084

Closed TwitchBronBron closed 6 months ago

TwitchBronBron commented 7 months ago

The m for an AA method inside a class appears to be incorrect. In the example below, I would expect m to be the type of whatever the AA type is, or in this case IBenchmark. But brighterscript thinks it's Suite

image

markwpearce commented 7 months ago

for version 1, I think we could fix this so that a function inside an AA literal will add an entry to the symbol table for m to be a plain AA ... it's harder to do the prediction of "expected" type...

Although for v1.1, we could probably do "expected type" and support a few use cases:

AALiteral added to an array:

data = [] as SomeInterface[]

data.push({
    func: function()
        ' `m` here is "SomeInterface"
    end function
})

AA Literal returned from a function

function test() as SomeInterface
    return {
        func: function()
            ' `m` here is "SomeInterface"
        end function
    }
end function

AA Literal in a typed assignment --- To be fair, this is sort of a general case that we could provide validation for!


myData as SomeInterface = {
    func: function()
       ' `m` here is "SomeInterface"
    end function
}
TwitchBronBron commented 7 months ago

Yeah I think those all make sense. I think what I care most about is that it's not wrong. So even if you just changed it to m as dynamic or ifAssociativeArray for now, that would be acceptable (but feel free to do the extra stuff you outlined)