asm-js / validator

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

Heap indexing expressions should be subtypes of intish #110

Open ghost opened 9 years ago

ghost commented 9 years ago

The latter half of section 6.10 of the specification describes the conditions for valid heap indexing expressions. One of them is:

ValidateExpression succeeds for expr with type intish;

which should read

ValidateExpression succeeds for expr with a subtype of intish;

The following module, for example, is correctly accepted by OdinMonkey's validator:

(function(std, ffi, buff) {
  "use asm"
  var H32 = new std.Int32Array(buff)
  function f(x, y) {
    x = x|0
    y = y|0
    H32[x >> 2] = y
  }
  return f
})

Note that the indexing expression x in H32[x >> 2] has type int <: intish.

The specification does not appeal to expression subsumption elsewhere, so this ought to be made explicit as a matter of consistency.