2

I finally got to the point where my javascript code compiles in the google closure compiler without any errors or warnings. Now I want to recompile the code generated and when I paste that code back into the compiler, I get over 100 warnings: most of them are JSC_REDECLARED_VARIABLE and a few JSC_INEXISTENT_PROPERTY.

Why is that?

enter image description here

3
  • Can you show an example to reproduce this error? It sounds quite unlikely atm (the JSC_REDECLARED_VARIABLE error, for example, would mean that GCC creates code which declares the same variable at least twice).
    – Rob W
    Commented Mar 19, 2012 at 14:11
  • @RobW: Here's a screenshot of the problem; the list just goes on.
    – frenchie
    Commented Mar 19, 2012 at 14:16
  • The core js file alone is about 4000 lines with function calls everywhere; can't just do a reduced demo.
    – frenchie
    Commented Mar 19, 2012 at 14:32

2 Answers 2

1

I do not think the Google Closure Compiler produces code that is intended for further compilation.

To have code compile correctly you have to keep some structure. But that extra structure is among the things removed by the compiler and without it the compiler cannot correctly interpret the code.

You should be able to do the easier modes of compilation but not the advanced one.

7
  • I tried to compile my code in simple mode first and then copy that output to make an advanced compilation: same problems. It looks like all the problems come from this kind of line: function ...(a) { ... a= it doesn't like the function parameter getting a new assignment
    – frenchie
    Commented Mar 19, 2012 at 14:28
  • Best is probably to only compile once. Why do you want to compile twice? Commented Mar 19, 2012 at 14:47
  • Well I plan to do a double obfuscation so I wanted to see what the code generated by the google compiler would look like before pasting it into an obfuscator. But may be a double-anything may not be the best thing to do.
    – frenchie
    Commented Mar 19, 2012 at 14:50
  • Google Compiler is not the best for obfuscation. While the resulting code might look intimidating, if you run it through a beutifier it gets pretty nice to look at. real JS obfuscation uses a lot of other techniques to make it very hard to decipher, including multiple levels of eval to defeat beutifiers. But even that can be parsed if you really want to, it's just a matter of time. Commented Mar 19, 2012 at 16:59
  • Yes, I'm aware that obfuscation only buys time but that's what I'm looking for. I'm going to obfuscate the output of that google compiler in jscrambler. Do you have an obfuscator you recommend?
    – frenchie
    Commented Mar 19, 2012 at 17:57
0

REDECLARED_VARIABLE is a WARNING not an error. It is intended to indicate a likely problem to the developer. A developer might ignore this if they know what they are doing and the compiler does.

Not the answer you're looking for? Browse other questions tagged or ask your own question.