sweet-core
sweet-core copied to clipboard
TypeError: decl.init.body is undefined
When I enter
syntax fn = function (ctx) {
let args = ctx.next().value;
let body = ctx.next().value;
return #`function ${args} ${body}`;
}
(fn () {
return 42;
})
into the online editor I get this error message:
TypeError: decl.init.body is undefined
I'm using Firefox Nightly version 49.0a1.
Your example is actually not a valid program because of ASI. It's actually getting parsed as:
syntax fn = function (ctx) {
let args = ctx.next().value;
let body = ctx.next().value;
return #`function ${args} ${body}`;
}(fn () {
return 42;
})
Add the necessary ;
and everything works out fine (yet another nail in the coffin of semicolon-less style).
That said I'm leaving this issue open so we can make a better error message. It should be able to say the {
at (fn () { ...
is invalid.
Oh, thanks.