Closed Bug 551763 Opened 14 years ago Closed 14 years ago

sputnik S13_A11_T1 - 'delete arguments' in a function deletes global.arguments

Categories

(Core :: JavaScript Engine, defect)

Other Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jorendorff, Assigned: cdleary)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file, 2 obsolete files)

Sputnik test S13_A11_T1 fails in SpiderMonkey. Here's a slightly different test I wrote that shows exactly what's going wrong:

var arguments = 7;
function f() {
    assertEq(delete arguments, false);   // fails
}
f();
assertEq(arguments, 7);  // fails; we deleted the global
print(" PASSED!");

The easiest thing might be to compile `delete arguments` to `false` in the front end.
Related to bug 530650?
(In reply to comment #1)
> Related to bug 530650?

Yes, I was about to point that one out. Luke knows about it too, since the patch in that bug classifies functions that use arguments (or could use arguments), and flags them.

/be
Assignee: general → cdleary
Attached patch Arguments deletion fix. (obsolete) — Splinter Review
We're only broken on lightweight functions; i.e.

js> function f() { print(delete arguments) } 
js> function g() { print(delete arguments); with(this) {} }
js> f(), g()
true
false

The heavyweight lookup resolves 'arguments appropriately via JSOP_DELNAME through js_FindProperty. We could just flip it to heavyweight if we see somebody is trying to delete 'arguments. Alternatively, we could return false when we see a deletion of 'arguments in a lightweight function invocation in the JSOP_DELNAME implementation.

We actually mark as heavyweight on assignment to arguments in the parser's NoteLValue function, so doing the same on deletion seems reasonable. Patch including test cases is attached.
Attachment #432252 - Flags: review?(jorendorff)
Attachment #432252 - Flags: review?(jorendorff) → review+
Comment on attachment 432252 [details] [diff] [review]
Arguments deletion fix.

Nice fix. The only nit is that trace-tests are for testing the tracing JIT.

So please put the test someplace like js/src/tests/js1_8_5/regressions/regress_551763.js, add a line to the jstests.list file in that directory, and to make the test pass in the test-runner, add

  print(" PASSED!");

at the end.

(You could instead call reportCompare -- but then your test depends on a function provided by the test-runner, and ideally tests should also run standalone in the shell, if possible.)
(In reply to comment #4)
>
> test-runner, add
> 
>   print(" PASSED!");
> 
> at the end.
> 
> (You could instead call reportCompare -- but then your test depends on a
> function provided by the test-runner, and ideally tests should also run
> standalone in the shell, if possible.)

Will that work when the test is run in the browser? print() does something altogether different there. I think reportCompare is needed anyway for that situation.
browser.js defines print() to do a document.write.

I don't know how the jsreftest runner works, but browser.js doesn't overload the reportCompare function.
Attached patch Fix arguments deletion. (obsolete) — Splinter Review
Puts test in the right place.
Attachment #432252 - Attachment is obsolete: true
Attachment #432649 - Flags: review?(jorendorff)
Attachment #432649 - Flags: review?(jorendorff) → review?(jim)
Update -- this has been sitting for a while.
Attachment #432649 - Attachment is obsolete: true
Attachment #442849 - Flags: review?(jwalden+bmo)
Attachment #432649 - Flags: review?(jim)
Attachment #442849 - Flags: review?(jwalden+bmo) → review+
Comment on attachment 442849 [details] [diff] [review]
Arguments deletion fix and tests.

Separate each test into its own file -- in particular, at the very least the two global tests both test the same thing, because the scope of a |var| in global scope is the entire script -- *not* just after it in source order.
Status: NEW → ASSIGNED
http://hg.mozilla.org/mozilla-central/rev/24a3be30208e
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: