Closed Bug 492150 Opened 15 years ago Closed 15 years ago

Unexpected error occurred when javascript.options.strict is true

Categories

(Core :: JavaScript Engine, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla1.9.1

People

(Reporter: masayuki, Assigned: brendan)

References

Details

(Keywords: fixed1.9.1, regression, Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file, 1 obsolete file)

This is reported to bugzilla-jp and contributors checks this bug.

See the testcase: http://bugzilla.mozilla.gr.jp/attachment.cgi?id=4029

> <script type="application/x-javascript">
> 
> try {
> 	throw 'foo';
> }
> catch(e) {
> 	var e = 'bar';
> }
> document.write('OK');
> 
> </script>

If the catch block defines var with defined name, the line throw an error *only* when javascript.options.strict is true.

Sakai-san proposes a patch:
http://bugzilla.mozilla.gr.jp/attachment.cgi?id=4030&action=diff

He guesses that this is a mistake of bug 487209.
Flags: blocking1.9.1?
Attached patch Patch v1.0 (obsolete) — Splinter Review
It's same as the patch already attached to bugzilla.mozilla.gr.jp, Nakano-san mentioned.
Attachment #376517 - Flags: review?(brendan)
Comment on attachment 376517 [details] [diff] [review]
Patch v1.0

Oops, sorry about this -- should have seen it. But let's get mrbkap's less biased review here. Thanks for the patch!

/be
Attachment #376517 - Flags: review?(brendan) → review?(mrbkap)
Easy fix, should take if not a blocker (this bug is a regression from 3.0.x).

/be
Flags: wanted1.9.1?
Assignee: general → brendan
Status: NEW → ASSIGNED
Priority: -- → P1
Target Milestone: --- → mozilla1.9.1
Comment on attachment 376517 [details] [diff] [review]
Patch v1.0

This is the right fix, but I wonder if it might be better to common out the now non-trivial condition like:

            bool error = op == JSOP_DEFCONST ||
                         dn_kind == JSDefinition::CONST ||
                         (dn_kind == JSDefinition::LET &&
                          (stmt->type != STMT_CATCH || OuterLet(tc, stmt, atom)));
            if (JS_HAS_STRICT_OPTION(cx)
                ? op != JSOP_DEFVAR || dn_kind != JSDefinition::VAR
                : error) {
                name = js_AtomToPrintableString(cx, atom);
                if (!name ||
                    !js_ReportCompileErrorNumber(cx, TS(tc->compiler), pn,
                                                 (!error)
                                                 ? JSREPORT_WARNING | JSREPORT_STRICT
                                                 : JSREPORT_ERROR,
                                                 JSMSG_REDECLARED_VAR,
                                                 JSDefinition::kindString(dn_kind),
                                                 name)) {
                    return JS_FALSE;
                }
            }

I'll leave it up to brendan to have the final word on that.
Attachment #376517 - Flags: review?(mrbkap) → review+
Flags: wanted1.9.1? → wanted1.9.1+
Flags: blocking1.9.1?
Attachment #376517 - Attachment is obsolete: true
Attachment #376635 - Flags: review+
Fixed:

http://hg.mozilla.org/tracemonkey/rev/c8a11e7cde90
http://hg.mozilla.org/mozilla-central/rev/6ea54bfd7c28

/be
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Whiteboard: fixed-in-tracemonkey
Flags: in-testsuite?
Summary: Unexpected error occurred when japascript.options.strict is true → Unexpected error occurred when javascript.options.strict is true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: