New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spec should tighten restrictions on number of parameter type coercions. #68

Closed
cscott opened this Issue Jun 8, 2013 · 2 comments

Comments

Projects
None yet
2 participants
@cscott

cscott commented Jun 8, 2013

The spec doesn't explicitly mention in section 5.1 that there must be exactly as many parameter type coercion statements as there are formal parameters. That is, the following is invalid:

function f(x, y) {
  x = x|0;
  x = x|0;
  y = x|0;
  return 42;
}

The other case is a little more obviously invalid (the spec says, "Every parameter in an asm.js function is provided with an explicit type annotation"):

function f(x) {
   return 42;
}

(My asm.js parser initially used a very generous parsing rule which required backtracing and allowed repeated coercions like the first example; only after reading the AsmJS.cpp source did I realize this was unnecessary.)

It should be obvious that

function(x,y) {
  x = x|0, y = y|0;
  return 42;
}

is also invalid.

@timmutton

This comment has been minimized.

Show comment
Hide comment
@timmutton

timmutton Jun 12, 2013

It might also be worth mentioning that x |= 0 is also not a valid coercion

timmutton commented Jun 12, 2013

It might also be worth mentioning that x |= 0 is also not a valid coercion

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Aug 12, 2014

I think this is fixed now. Section 6.4 establishes the correspondence between parameters and parameter type annotation by using the same identifier sequence (x...), later saying "by mapping each each parameter x to its corresponding parameter type annotation" and then adding "annotations must appear in the same order as the parameters".

ghost commented Aug 12, 2014

I think this is fixed now. Section 6.4 establishes the correspondence between parameters and parameter type annotation by using the same identifier sequence (x...), later saying "by mapping each each parameter x to its corresponding parameter type annotation" and then adding "annotations must appear in the same order as the parameters".

@ghost ghost closed this Aug 12, 2014

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment