Closed Bug 132217 Opened 23 years ago Closed 23 years ago

delete on global function should not delete the function

Categories

(Rhino Graveyard :: Core, defect)

x86
Windows NT
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: pschwartau, Assigned: norrisboyd)

Details

This is the Rhino version of bug 131964 against SpiderMonkey.
The testcase for this bug is 

          mozilla/js/tests/ecma_3/Function/regress-131964.js

At present, it tests four scenarios:

1. f defined and deleted in global scope
2. f defined and deleted in function scope
3. f defined and deleted in eval scope
4. f defined in eval scope, but deleted in global scope

I'm still trying to sort out what the expected behavior should be
for 3 and 4, but ECMA seems pretty clear about 1 and 2: f should not
be deleted in those cases.

Here are the ECMA references quoted by Thomas Much in the original bug:

> ECMA 262-3, section 13 says that function declarations create a property
> of the current variable object as specified in 10.1.3.

> 10.1.3 says that for function declarations, the property's attributes
> are determined by the type of the code.

> 10.2.1 says that for global code, variable instantiation is performed
> [...] using property attributes { DontDelete }.


And there are similar sections for function scope and eval scope...
Fixed:

Checking in Interpreter.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/Interpreter.java,v  <--  In
terpreter.java
new revision: 1.74; previous revision: 1.73
done
Checking in ScriptRuntime.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java,v  <--
ScriptRuntime.java
new revision: 1.87; previous revision: 1.86
done
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Reopening bug -


-------------------    SUMMARY OF TEST RESULTS    ---------------------------
The test above checks delete of functions defined in

1. global scope
2. function scope
3. eval scope (delete also done within eval scope)
4. eval scope (delete done in global scope)


-------------------    OUTPUT BEFORE PATCH    ---------------------------
FAILED!: Section 1 of test -
FAILED!: Expected value 'f lives!', Actual value 'f was deleted'

FAILED!: Section 2 of test -
FAILED!: Expected value 'f lives!', Actual value 'f was deleted'


-------------------    OUTPUT AFTER PATCH    ----------------------------
FAILED!: Section 3 of test -
FAILED!: Expected value 'h was deleted', Actual value 'h lives!'

FAILED!: Section 4 of test -
FAILED!: Expected value 'k was deleted', Actual value 'k lives!'


So the patch has fixed the bug in global and function scope, but
has changed the behavior in eval scope. It used to be that functions
defined in eval scope were deletable; now apparently they are not.
According to ECMA, they should be. See discussion in bug 131964.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Fixed: 

Checking in Interpreter.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/Interpreter.java,v  <--  In
terpreter.java
new revision: 1.75; previous revision: 1.74
done
Status: REOPENED → RESOLVED
Closed: 23 years ago23 years ago
Resolution: --- → FIXED
Verified FIXED -

The testcase passes in both the rhino and rhinoi shells on WinNT.
Status: RESOLVED → VERIFIED
Targeting as resolved against 1.5R4
Target Milestone: --- → 1.5R4
You need to log in before you can comment on or make changes to this bug.