RFE: Javascript future keywords should generate warnings when used as identifiers

RESOLVED WORKSFORME

Status

Toolkit Graveyard
Error Console
--
enhancement
RESOLVED WORKSFORME
11 years ago
2 years ago

People

(Reporter: Adam Constabaris, Unassigned)

Tracking

Details

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.5) Gecko/20070718 Fedora/2.0.0.5-1.fc7 Firefox/2.0.0.5
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.5) Gecko/20070718 Fedora/2.0.0.5-1.fc7 Firefox/2.0.0.5

This is mainly a cross-browser compatibility issue; the JS interpreters Safari 2.x (Mac/Intel), as well as in the 3.0 betas for Windows, die a screaming death (i.e. stop executing) if they encounter a future keyword, e.g. 'abstract' as an identifier.

http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Reserved_Words

While that reaction seems extreme to me, it would probably be useful if use of a future keyword generated a warning in the Error console.

I can't get that usage to even come up as a warning in FireFox 2.0.0.5 on any of Mac/Intel, WinXP and Linux i686. 

Reproducible: Always

Steps to Reproduce:
1. use 'abstract' (or any JS 1.5 future keyword) as an identifier in a script
2. open Error Console

Actual Results:  
No errors, warnings, or messages of any sort are generated by the use of the keyword in a (may-someday-be) incorrect fashion.

Expected Results:  
A warning should be visible.

Comment 1

11 years ago
Input: var abstract = 1;

Warning: abstract is a reserved identifier
Source file: javascript: var abstract = 1
Line: 1, Column: 5
Source code:
 var abstract = 1;

You'll need to set javascript.options.strict=true to see that error.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → WORKSFORME
(Reporter)

Comment 2

11 years ago
Thanks!  Setting the strictness flag fills the immediate need.  It didn't even occur to me to see if there was a setting for that.

I suppose if there's a lingering idea for an enhancement it would be to have a wider range of configuration options here (e.g. the ability to specifically set future reserved words== warning), but with the changes coming down the pike for 2.0 that seems pretty low priority.

Cheers
(Assignee)

Updated

10 years ago
Product: Firefox → Toolkit
(Assignee)

Updated

2 years ago
Product: Toolkit → Toolkit Graveyard
You need to log in before you can comment on or make changes to this bug.