colhountech / js2-mode

Automatically exported from code.google.com/p/js2-mode
0 stars 0 forks source link

Components.utils.import() not parsed correctly #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Write this code:

const Cu = Components.utils;
Cu.import("...");

Then move the cursor above it and type C-x '

What is the expected output? What do you see instead?

You'll get an error in the '.' before 'import', presumably because it's
interpreting 'import' as a keyword, which is not correct in this case (I
think).

What version of the product are you using? On what operating system?

Aquamacs 1.3, OS X Leopard

Please provide any additional information below.

Thanks for your work so far!  I'm really excited about having a solid js
mode for emacs.

Original issue reported on code.google.com by vthun...@gmail.com on 31 Mar 2008 at 9:15

GoogleCodeExporter commented 8 years ago
Sooo... this actually isn't legal JavaScript:  not in IE, not in Firefox, and 
not in
Mozilla Rhino.  They all throw errors if you try to set an "import" property on 
an
any object, so there's no way to call import() on an object.

I'm surprised you're seeing that it's legal in some particular environment.  Is 
it
when writing Firefox extensions and/or XUL apps?  If so, I can add a 
configuration
option to permit it as an identifier.

Original comment by steve.ye...@gmail.com on 14 Apr 2008 at 10:35

GoogleCodeExporter commented 8 years ago
Steve try this code in the Firefox error console, it works just fine:

var foo = {};
foo.import = function () { return 42; };
foo.import();

I don't have a plain spidermonkey or xpcshell handy though. 
Components.utils.import
is a new feature in Firefox, used by both extensions and xul apps.

Original comment by dlb...@gmail.com on 14 Apr 2008 at 10:59

GoogleCodeExporter commented 8 years ago
I verified that Firefox lets you use keywords as property names.  IE and Rhino 
do
not, and technically Ecma-262 forbids it.  I'll have to submit a Rhino bug and 
have
them chew on it.

In the meantime, I'll add an option that permits it in js2-mode, but it'll have 
to be
off by default since it's not really legal JavaScript.

Original comment by steve.ye...@gmail.com on 14 Apr 2008 at 11:36

GoogleCodeExporter commented 8 years ago
Yea, that's fine. Perhaps a different error message when the identifier is a 
keyword?
One that mentions the option would be nice.

Original comment by dlb...@gmail.com on 14 Apr 2008 at 11:50

GoogleCodeExporter commented 8 years ago
Fixed in the svn repository.  Will be available as a new option
(js2-allow-keywords-as-property-names) in next release.

Original comment by steve.ye...@gmail.com on 14 Apr 2008 at 12:12

GoogleCodeExporter commented 8 years ago

Original comment by steve.ye...@gmail.com on 16 Apr 2008 at 9:45

GoogleCodeExporter commented 8 years ago

Original comment by steve.ye...@gmail.com on 19 Apr 2008 at 10:53

GoogleCodeExporter commented 8 years ago
Arg, my notifications for this bug were going to a black hole.  Yes, this is for
writing Firefox extensions, where it is legal.  Thanks for adding the option 
for it!

Original comment by vthun...@gmail.com on 21 May 2008 at 1:27