Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

"int" is a reserved word and will cause a compiler error when using closure compiler #1304

Closed
srcspider opened this issue Aug 28, 2012 · 14 comments

Comments

@srcspider
Copy link

"int" is a reserved word

http://msdn.microsoft.com/en-us/library/ttyab5c8.aspx

I see it's merely used as syntactic sugar for parseInt(value, 10). It would be nice if it was removed or refactored into some other name so the unminified version works when compiling with closure compiler.

@mhevery
Copy link
Contributor

mhevery commented Aug 31, 2012

Err, we compile with closure compiler and it works. Can you be more specific about the line number you are reffering to. Closing in the meantime.

@mhevery mhevery closed this as completed Aug 31, 2012
@jaiew
Copy link

jaiew commented Dec 2, 2012

I'm trying to compile angular 1.0.2 with closure just using SIMPLE_OPTIMIZATIONS and I'm getting the same error.
Here is the output from the compilation: http://pastebin.com/1rq3wwsS

@jaiew
Copy link

jaiew commented Dec 2, 2012

The solution is to use --language_in ECMASCRIPT5_STRICT as an option to the closure compiler.

@kennardconsulting
Copy link

Hi guys.

Thanks for doing an awesome job on AngularJS!

I have struck this same error when trying to compile 'angular.js' (1.0.3) with Apache Rhino (1.7R2). It complains with the following errors:

'identifier is a reserved word' (it's talking about 'int' being used as a function name) on the following lines:

#60: msie = int((
#206: function int(str) {
#4899: port: int(match[5])
#8156: android = int((/android (\d+)/.exec(lowercase($window.navigator.userAgent)) || [])[1]);
#9861: tzHour = int(match[9] + match[10]);
#9862: tzMin = int(match[9] + match[11]);
#9864: date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3]));
#9865: date.setUTCHours(int(match[4]||0) - tzHour, int(match[5]||0) - tzMin, int(match[6]||0), int(match[7]||0));
#9881: date = int(date);
#10029: limit = int(limit);
#11302: var minlength = int(attr.ngMinlength);
#11319: var maxlength = int(attr.ngMaxlength);

'identifier is a reserved word' (it's talking about 'short') on the following line:

#9155: short: 'M/d/yy h:mm a'

Is there any way we could avoid using reserved words in angular.js? It seems like a minor change and would improve cross-JavaScript Interpreter compatibility? If I fix these errors manually Rhino is happy.

Regards,

Richard.

@srcspider
Copy link
Author

@jaiew

Thanks for the tip!

@kennardconsulting
Copy link

srcspider: no probs. Can you reopen this issue, then?

@srcspider
Copy link
Author

@kennardconsulting I believe @mhevery would have to reopen it. As the one who started the issue my rights on open/close only go as far as closing an issue I have opened (not vise versa).

@kennardconsulting
Copy link

FYI: This same problem also impacts angular-scenario.js

@jaiew
Copy link

jaiew commented Dec 21, 2012

@kennardconsulting There's been some es5 updates to rhino since 1.7R2 try updating to 1.7R4 that may fix your issue.

@kennardconsulting
Copy link

Yes that worked! Brilliant, thanks.

@Crozin
Copy link

Crozin commented Jun 5, 2014

The same problem occurs when I try to minify Angular with newest (2.4.8) YUIComporessor. It would be really nice if Angular wouldn't use reserved keywords as @kennardconsulting mentioned.

@mhevery any chances for reopening this issue?

@rodyhaddad
Copy link
Contributor

If someone wants to rename the reserved words that angular uses and send a PR of that, I'm pretty sure it would get merged.

@stefanofornari
Copy link

+1 to merge this PR. using a so common reserved word is potentially very annoying.

@rodyhaddad
Copy link
Contributor

@stefanofornari seems to have been done #10591 :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants