asm-js / validator

A reference validator for asm.js.
Apache License 2.0
1.78k stars 148 forks source link

Accept comma-separated function table declarations #100

Open ghost opened 9 years ago

ghost commented 9 years ago

This issue mimics #63 for function table declarations. The production is given in section 5.6 of the specification as follows:

var x:Identifier = [ f0:Identifier (, f:Identifier) ... ] ;

(I've added parentheses in the metalanguage, on the assumption that the postfix ellipsis notation used throughout the specification denotes the operand's Kleene closure.)

However, OdinMonkey's validator accepts comma-separated function table declarations of the form:

var x0:Identifier = [ f0:Identifier (, f0:Identifier) ... ] (, x1:Identifier = [ f1:Identifier (, f1:Identifier) ... ]) ... ;

Consider, for example, the following valid module:

(function() {
    "use asm"
    function f() {}
    function g() {}
    var x = [f], y = [g], z = [f, g]
    return f
})
sunfishcode commented 9 years ago

The js validator (as of 7ef85ddc8630f184230e9d31c1d990dc88ef3577) and OdinMonkey both accept this code, so this appears to be a minor oversight in the spec.

dead-claudia commented 9 years ago

It likely is. And a PR has been made. @dherman? #106