tern icon indicating copy to clipboard operation
tern copied to clipboard

Function declaration not hoisted

Open MaxSchlueter opened this issue 6 years ago • 0 comments
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.

MaxSchlueter avatar Nov 26 '18 02:11 MaxSchlueter