HoriSun / closure-compiler

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

Namespace warnings in advanced compilation mode cannot be disabled #1225

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a file the produces this warning.
// Produces JSC_UNSAFE_NAMESPACE warning:
var a = {};
a.b = {};
/** @constructor */
a.b.c = function(){
  this.msg = 'hi';
};
var d = a.b;

2. Compile with Advanced optimization enabled.  This produces the warning as 
expected.  This code compiles successfully and runs as expected, but it is 
suboptimal. 
3. Look for a way to turn off this warning. 

Expected: 
I would expect to be able to turn off this warning independent of other 
warnings.

Actual: 
Only way was able to silence this warning was to change warning level to 
"quiet" which turns off all warnings.

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

Please provide any additional information below.

Original issue reported on code.google.com by Bitwise...@gmail.com on 3 Feb 2014 at 7:34

GoogleCodeExporter commented 9 years ago
Here's a patch that would fix this without breaking backward compatibility with 
the current behavior. 
Wiki would need to be updated as well.

Original comment by Bitwise...@gmail.com on 3 Feb 2014 at 8:01

Attachments:

GoogleCodeExporter commented 9 years ago
i thought the general direction we were heading was to make these warnings into 
un-suppressable errors, because they really are signs that the compiler is 
breaking your code. I'll let the google people weigh in on this.

Original comment by Nicholas.J.Santos on 4 Feb 2014 at 5:37

GoogleCodeExporter commented 9 years ago
Right, I don't think we support namespace aliasing.

Original comment by dim...@google.com on 4 Feb 2014 at 6:14

GoogleCodeExporter commented 9 years ago

I know I'm being dumb believing the comments, but this says otherwise. 
https://code.google.com/p/closure-compiler/source/browse/src/com/google/javascri
pt/jscomp/CollapseProperties.java#157

And from what I can see the code backs me up.  You're checking if it is safe to 
do, and then doing so only if it is.  

But I understand the direction - The compiler isn't breaking my code yet, but I 
should expect that it will begin to do so sometime soon. 

Original comment by Bitwise...@gmail.com on 5 Feb 2014 at 8:21

GoogleCodeExporter commented 9 years ago
That comment is accurate, but doesn't mean what you seem to think it means.

Original comment by Nicholas.J.Santos on 6 Feb 2014 at 11:19

GoogleCodeExporter commented 9 years ago
Thanks for that bit of ominous.  :)  So what does it mean? 

Original comment by liam.c.n...@gmail.com on 7 Feb 2014 at 8:06