tern
tern copied to clipboard
Function declaration not hoisted
trafficstars
I found that function declarations in a file are not hoisted when an effect is executed. For the following file:
foo(id)
function id(x) { return x; }
And the following plugin:
const defs = {
"foo": "fn(arg: ?) -> !custom:someEffect"
}
infer.registerFunction("someEffect", function (self, args, argNodes) {
const arg = args[0] // arg has no type
})
Though if you put the function declaration at the top of the file, the arg has the desired function type.