Closed Bug 878526 Opened 6 years ago Closed 6 years ago

OdinMonkey: Disallow "return foreignFun();"

Categories

(Core :: JavaScript Engine, defect)

x86_64
macOS
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: jruderman, Assigned: luke)

References

Details

(Keywords: testcase)

Attachments

(1 file)

function module(stdlib, foreign)
{
  "use asm";
  var kPASS = foreign.kPASS;
  function f() {
    return kPASS();
    return;
  }
  return f;
};

print(module(this, {kPASS: function() { return "PASS"; }})());

asm.js result: undefined
normal result: PASS

OdinMonkey should reject this module saying "unknown is not a subtype of void".

I noticed this reading https://bugzilla.mozilla.org/show_bug.cgi?id=846317#c1.
Attached patch fix and testSplinter Review
Hah, great corner case.  The idea is that "unknown" isn't actually used internally (we'd have to represent the union of a double/int32), but rather the use is propagated inward and that, in turn, determines the ffi call's return type.  When there is no coercion, I used the type "void", thinking that there's nothing you can do with a void.  However, I forgot the quirk that asm.js lets you return void-valued expressions if the declared return type is void!  So, looks like we need Type::Unknown after all since it is not returnable.
Assignee: general → luke
Status: NEW → ASSIGNED
Attachment #760071 - Flags: review?(bbouvier)
Attachment #760071 - Flags: review?(bbouvier) → review+
Depends on: 881608
https://hg.mozilla.org/mozilla-central/rev/9ce9c145e072
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
You need to log in before you can comment on or make changes to this bug.