Closed Bug 410469 Opened 18 years ago Closed 5 years ago

var foo = [].foo; does not generate expected(?) strict warning

Categories

(Core :: JavaScript Engine, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: neil, Unassigned)

References

()

Details

Operations on [].foo used to always generate a strict JavaScript warning "reference to undefined property [].foo". Some of these warnings were turned off for ! && || ?: etc. but they also seem to have been turned off for =, which I'm not sure was expected. For instance, bar([].foo) generates a warning.
OS: Windows XP → All
Please attach (or inline if small) a specific testcase. /be
the url triggers: Warning: assignment to undeclared variable bar Source file: javascript:bar%20=%20[].bar;%20var%20foo%20=%20[].foo;%20baz%20=%20[].baz; Line: 1 Warning: assignment to undeclared variable baz Source file: javascript:bar%20=%20[].bar;%20var%20foo%20=%20[].foo;%20baz%20=%20[].baz; Line: 1 but no mention of foo.
URL: javascript:bar%20=%20[].bar;%20var%20...
Kinda unreadable with all those %20s, but ok. This is intentional; see bug 248549. Had to use cvs annotate to remind myself. /be
INVA then?
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago
Resolution: --- → INVALID
Bug 248549 is pretty long. Are any comments in that bug especially relevant to this bug?
I wouldn't go that far. The "detecting" logic is being used to good effect for things like undetected document.all support, but strict warnings could still be given for certain opcode sequences that should be considered "detecting". This would require yet another opcode format flag, or a special case for an existing flag, or for a specific op. I'm not going to take this bug, but one idea is to use the existing JOF_SET flag as the special case: if it is set for the next op after the GET op that triggers the call to Detecting (jsobj.c), then (as today) Detecting should return true, but it could give a strict warning. /be
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Sorry, comment 6 was in reply to comment 4. Re: comment 5: I was looking through all the noise and drama, and I could not find the reasoning for including JOF_DETECTING among the JSOP_SET* opcodes' format flags -- I do recall it being necessary based on real-world pages that use (or used, this was 2004) undetected document.all. /be
Status: UNCONFIRMED → NEW
Ever confirmed: true
So people try to detect IE using var all = document.all; if (all) ...?
(In reply to comment #8) > So people try to detect IE using var all = document.all; if (all) ...? Yes, something like that. Perhaps bclary can scan for it and find some alexa top 1000 examples, but this was what jst and I were contending with, circa 2004. /be
(In reply to comment #9) closely related examples are in bug 259935 and bug 260685. the obj.ie stuff is still out there and is probably still used. Looking for a = document.all; ... if (a)... would take a while and require manual inspection of the matches to .all. I'll do it if there is a benefit to knowing the current answer, but not just for idle curiosity.
Blocks: 296661
Assignee: general → nobody

No longer valid after bug 1619177.

Status: NEW → RESOLVED
Closed: 18 years ago5 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.