HoriSun / closure-compiler

Automatically exported from code.google.com/p/closure-compiler
0 stars 0 forks source link

Necessary space after the "in" keyword is sometimes removed #1295

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a JS file which uses the ("key" in obj) pattern
2. Do not use the --formatting PRETTY_PRINT command line option

What is the input?
if ("recurrence" in json) this.recurrence = !json.recurrence ? [] : 
json.recurrence.map(/** @this Schedule */Schedule_fromJSON, this)

What is the expected output?
"recurrence"in a&&(this.recurrence=a.recurrence?a.recurrence.map(D,this):[]
              ^
What do you see instead?
"recurrence"ina&&(this.recurrence=a.recurrence?a.recurrence.map(D,this):[]
              ^
What do you see with pretty-print enabled?
"recurrence" in a && (this.recurrence = a.recurrence ? a.recurrence.map(D, 
this) : []
               ^

What version of the product are you using? On what operating system?
Version: v20140110
Built on: 2014/01/14 16:25
Windows 7 (x64)

Please provide any additional information below:
It happens only in very large (long) script files.  The character number 
(column) from my output file where I see this error, the "in" begins at 61,103. 
 This only happens infrequently, and I can't seem to create a test-case for it. 
 When using pretty-print, the issue does not exist.

I typically run the compiler using the following command line:
java -jar
--charset UTF-8
--language_in ECMASCRIPT5_STRICT
--compilation_level ADVANCED_OPTIMIZATIONS
--use_types_for_optimization
--accept_const_keyword
--manage_closure_dependencies
--warning_level VERBOSE
--externs "c:\path\extern1.js" --externs "c:\path\extern2.js"
--js_output_file "c:\path\output.js"
"c:\path\input.js"

Original issue reported on code.google.com by alein@trakitwireless.com on 5 Apr 2014 at 12:52

GoogleCodeExporter commented 9 years ago
I can't repro this with trivial cases.  But as the column is 61,103, I'm 
guessing you are using something to strip newlines after the compiler is done 
processing?  Typically, the compiler will break the line at ~500 characters 
unless you tell it otherwise.   When people do this manually, the usually 
forget to replace the newline with a space.   

Original comment by concavel...@gmail.com on 5 Apr 2014 at 11:51

GoogleCodeExporter commented 9 years ago
Just using the command line tool; no extra processing. 
Also, with the pretty-print option enabled, the space is inserted. It's a space 
I'm missing, not the new line character. 

Original comment by alein@trakitwireless.com on 5 Apr 2014 at 11:57

GoogleCodeExporter commented 9 years ago
how are you getting the compiler to create output files with 60K characters in 
a line? I can't get this to happen with normal code.

Original comment by Nicholas.J.Santos on 7 Apr 2014 at 1:49

GoogleCodeExporter commented 9 years ago
Shit, nevermind.

I just stepped through the code and caught the output file before it was picked 
up by another process; the line-breaks are intact.

There is another process in our environment that uploads the output, and I was 
told that it just uploads the file as is. But once I read the source for that 
process, it seems to be removing all newline characters in JS and HTML (except 
inside the PRE tag) files only.

I'm sorry for wasting your time.

Original comment by alein@trakitwireless.com on 7 Apr 2014 at 2:10

GoogleCodeExporter commented 9 years ago

Original comment by tbreisac...@google.com on 7 Apr 2014 at 4:08