crypto icon indicating copy to clipboard operation
crypto copied to clipboard

Issue with uninitialised variable

Open elsassph opened this issue 4 years ago • 2 comments

This test:

m.it("Array has ifArray interface", sub()
    ' a = []
    m.assert.notEqual(GetInterface(a, "ifArray"), invalid, "Object doesn't have ifArray interface")
end sub)

fails with a JS runtime error (multiple times):

Runtime error encountered in BRS implementation:  TypeError: Cannot read property 'get' of undefined
    at impl (/path/to/project/node_modules/brs/lib/stdlib/GlobalUtilities.js:28:34)
    at interpreter.inSubEnv.subInterpreter (/path/to/project/node_modules/brs/lib/brsTypes/Callable.js:107:20)
    at Interpreter.inSubEnv (/path/to/project/node_modules/brs/lib/interpreter/index.js:138:20)
    at Callable.call (/path/to/project/node_modules/brs/lib/brsTypes/Callable.js:97:28)
    at inSubEnv.subInterpreter (/path/to/project/node_modules/brs/lib/interpreter/index.js:812:35)
    at Interpreter.inSubEnv (/path/to/project/node_modules/brs/lib/interpreter/index.js:138:20)
    at Interpreter.visitCall (/path/to/project/node_modules/brs/lib/interpreter/index.js:810:29)
    at Call.accept (/path/to/project/node_modules/brs/lib/parser/Expression.js:29:24)
    at Interpreter.evaluate (/path/to/project/node_modules/brs/lib/interpreter/index.js:1231:27)
    at Array.map (<anonymous>)

elsassph avatar Jul 10 '20 23:07 elsassph

Hey @elsassph what is the expected behavior here? On a real Roku device this would crash with a type mismatch because a is not initialized.

alimnios72 avatar Apr 14 '21 01:04 alimnios72

image It seems to not be an error but just providing an "uninitialized" variable.

There would be a type mismatch error if the function has a as type incompatible with "uninitialized"

elsassph avatar Apr 29 '21 16:04 elsassph