Closed Bug 289933 Opened 20 years ago Closed 19 years ago

new Script objects are callable but report typeof object instead of function

Categories

(Core :: JavaScript Engine, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.8beta4

People

(Reporter: bc, Assigned: mrbkap)

References

()

Details

(Keywords: fixed1.8)

Attachments

(1 file, 3 obsolete files)

1.7 builds report typeof (new Script()) as 'function', but 1.8 builds report
'object'.
Attached patch patch v1 (obsolete) — Splinter Review
Shaver tells me that Script does implement [[Call]], and so by the table in
11.4.3, typeof should, in fact, be returning "function". The regression is from
bug 246441. Brendan, why was the older version (just checking clasp->call !=
NULL) insufficient? This patch just fixes 'typeof(new Script())'.
Assignee: general → mrbkap
Status: NEW → ASSIGNED
Attachment #186607 - Flags: review?(brendan)
Target Milestone: --- → mozilla1.8beta3
IE reports |typeof /a/| as "object". I'm not sure if we want to dogmatically
stick to the spec here, or go for an (arguably more intuitive) interpretation
and emulate IE.
Attached patch just functions are functions (obsolete) — Splinter Review
patch v1 calls all of: regexps, scripts (in the new Script() sense), and
functions  "function".
this patch calls only functions "function". I'll also attach a patch that makes
scripts and functions "function".
This makes regexps "object", script and functions "function".
Attachment #186607 - Flags: review?(brendan)
For the record: I tested IE, Opera, and Safari, and all three browsers report
|typeof /a/| as being "object". Since Script is one of our things, we can do
whatever we want with it, which is why I've attached all 3 versions of the patch.
Also note bug 61911.
Attachment #186837 - Flags: review?(brendan)
Comment on attachment 186837 [details] [diff] [review]
just functions are functions

I'll try to get ECMA TG1 to specify this in a future Edition.

/be
Attachment #186837 - Flags: review?(brendan)
Attachment #186837 - Flags: review+
Attachment #186837 - Flags: approval1.8b4+
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Target Milestone: mozilla1.8beta3 → mozilla1.8beta4
test in js1_3/Script/script-001.js
Flags: testcase+
Can we please back this out again?

This patch breaks a ton of my sip code (http://www.croczilla.com/zap) which for
one reason or another needs to discriminate between objects and regexps.
I don't know how common this pattern is, but silently changing the behavior
without bumping the JS version is likely to lead to confusion more than anything
else.

Even the checkin comment is confused about what behaviour we now implement:

revision 3.211
date: 2005/07/16 02:03:26;  author: mrbkap%gmail.com;  state: Exp;  lines: +1 -3
bug 289933: make regexps and script objects be of type 'function' to imitate IE.
r+a=brendan
Status: RESOLVED → REOPENED
OS: Windows XP → All
Resolution: FIXED → ---
Yeah, I kind of botched that checkin message. I think backwards compat. with
Firefox 1.0.x might take precedence over compat. with other browsers. Brendan,
this would suggest that RegExp and Script should both be functions. What do you
think?
Attachment #186607 - Attachment is obsolete: true
Attachment #186837 - Attachment is obsolete: true
Attachment #186838 - Attachment is obsolete: true
Attachment #192852 - Flags: review?(brendan)
Status: REOPENED → ASSIGNED
Comment on attachment 192852 [details] [diff] [review]
functions, script objects, and regular expressions are functions

No need to over-parenthesize the || expression. Also, I'm guessing that dynamic
frequency of function object operand to typeof is higher than other classes, so
transpose the || operands. Finally, how about a comment before the clasp =
OBJ_GET_CLASS(cx, obj) line that starts the block, talking about ECMA [[Call]]
and citing chapter and verse?

Fix those and r+a=me, thanks!

/be
Attachment #192852 - Flags: review?(brendan)
Attachment #192852 - Flags: review+
Attachment #192852 - Flags: approval1.8b4+
Checked into MOZILLA_1_8_BRANCH and trunk. RegExps, Scripts, and functions are
all of type "function" now.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago19 years ago
Keywords: fixed1.8
Resolution: --- → FIXED
Depends on: 305959
FYI, this change broke view source after a form submission. See Bug 305959 for
details.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: