Closed Bug 333728 Opened 20 years ago Closed 20 years ago

|typeof (0, undef)| does not throw ReferenceError

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

VERIFIED FIXED
mozilla1.9alpha1

People

(Reporter: mqmq87, Assigned: mrbkap)

References

()

Details

(Keywords: verified1.8.1, Whiteboard: [patch])

Attachments

(2 files)

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040914 (not Googlebot) Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040914 (not Googlebot) : Reproducible: Always Steps to Reproduce: Assuming |undef| doesn't exist and |this| isn't null: typeof (0, undef) typeof (0 || undef) typeof (1 && undef) typeof (0 ? 0 : undef) typeof (1 ? undef : 0) typeof (!this ? 0 : undef) Actual Results: evaluate all to the string "undefined" Expected Results: should all throw ReferenceError, because ECMA specifies a GetValue() on |undef| before |typeof| becomes involved. Note that |typeof (this ? undef : 0)| has correct behaviour, but |typeof (1 ? undef : 0)| is erronously optimized to |typeof (undef)| (same bytecode), which doesn't call GetValue(). The code seems to be located here: http://lxr.mozilla.org/mozilla/source/js/src/jsinterp.c#3965
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9a1) Gecko/20060413 Firefox/3.0a1 - Build ID: 0000000000 Confirmed.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee: general → mrbkap
OS: Linux → All
Priority: -- → P3
Hardware: PC → All
Target Milestone: --- → mozilla1.9alpha
Status: NEW → ASSIGNED
Whiteboard: [patch]
Attached patch Fix, v1Splinter Review
Attachment #220065 - Flags: review?(brendan)
Comment on attachment 220065 [details] [diff] [review] Fix, v1 Thanks, now to resolve the conflict this will cause my generators patch in jsopcode.tbl! :-P /be
Attachment #220065 - Flags: review?(brendan) → review+
Fix checked into trunk.
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
I'll check this into the tree when it opens again. Is this test correct or is the fix incomplete? In todays Minefield build on winxp I get: BUGNUMBER: 333728 STATUS: Throw ReferenceErrors for typeof(...undef) FAILED!: Throw ReferenceErrors for typeof(...undef): typeof (0 ? 0 : undef) FAILED!: Expected value 'ReferenceError', Actual value 'undefined' FAILED!: FAILED!: Throw ReferenceErrors for typeof(...undef): typeof (1 ? undef : 0) FAILED!: Expected value 'ReferenceError', Actual value 'undefined' FAILED!:
Flags: in-testsuite?
I think you might be getting bitten by constant folding. When I try this in the shell, I see: js> function f() { return typeof(1 ? undef : 1); } js> dis(f) main: 00000: name "undef" 00003: group 00004: typeof 00005: return 00006: stop
Checking in regress-333728.js; /cvsroot/mozilla/js/tests/js1_5/Exceptions/regress-333728.js,v <-- regress-333728.js initial revision: 1.1 verified fixed 20060520
Status: RESOLVED → VERIFIED
Flags: in-testsuite? → in-testsuite+
fixed by Bug 336373 on the 1.8.1 branch. verified fixed 1.8.1 with windows/macppc/linux 20060707
Keywords: verified1.8.1
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: