plovr built from revision af7e74281eb347c743ef8209a53ec8f9da011d1f
Revision numbers for embedded Closure Tools:
Closure Library: 021ed5b313da392a7139d0d3cf7011999ac8b672
Closure Compiler: 39bb337fdd742e6318f7e38bce33663b5ed50472
Closure Templates: 50a0b6950bbe65cdd9d611db2e4ad690c0de4318
-Alex
noSideEffectExternMethod(); //This statement generates a warning and the code is kept.
var foo = noSideEffectExterMethod(); //This statement does not generate a warning and is removed.Also, it is somewhat difficult to force the compiler to keep such hidden side-effects without this behavior. Closure-library has a sink method, but it of course requires use of closure-library.
Chad Killingsworth
To view this discussion on the web visit https://groups.google.com/d/msgid/closure-compiler-discuss/CADKHWKg4JwHW%3D3eKm4DF5_AGOnwp%3DNdnZq7ZXu1tK-AoKj0rQg%40mail.gmail.com.
b1ea083.
Note that if I assign the result of the call to ns1.stringify to an otherwise unused local variable, I get the exact same result but with no build warning.
$ tail -n +1 *
==> index.html <==
<html>
<body>
</body>
<script src="lib.min.js"></script>
<script src="test.min.js"></script>
</html>
==> lib.js <==
var ns1 = {};
ns1.stringify = function(arg) {
return '' + arg;
}
==> externs.js <==
var ns1 = {};
/**
* @params {*} arg
* @nosideeffects
*/
ns1.stringify = function(arg) {};
==> test.js <==
(function() {
var str = "Hello World!";
ns1.stringify(str);
var el = document.createElement('div');
el.innerHTML = str;
document.body.appendChild(el);
})();
==> build.sh <==
#!/bin/sh
java -jar $CLOSURE_PATH \
--compilation_level WHITESPACE_ONLY \
--js_output_file lib.min.js \
--js lib.js;
java -jar $CLOSURE_PATH \
--compilation_level SIMPLE \
--externs externs.js \
--jscomp_warning uselessCode \
--js_output_file test.min.js \
--js test.js;
$ ./build.sh
test.js:3: WARNING - Suspicious code. The result of the extern function call 'ns1.stringify' is not being used.
ns1.stringify(str);
^
0 error(s), 1 warning(s)
$ tail -n +1 *.min.js
==> lib.min.js <==
var ns1={};ns1.stringify=function(arg){return""+arg};
==> test.min.js <==
(function(){ns1.stringify("Hello World!");var a=document.createElement("div");a.innerHTML="Hello World!";document.body.appendChild(a)})();
> email to closure-compiler-d...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/closure-compiler-discuss/dd815f58-3f25-4c51-b7d7-66bf8210ac7e%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/closure-compiler-discuss/17ba694a-31c1-4027-aa13-a01260299629%40googlegroups.com.--
---
You received this message because you are subscribed to a topic in the Google Groups "Closure Compiler Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/closure-compiler-discuss/ZH08VeWjTHo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to closure-compiler-d...@googlegroups.com.
noSideEffectExternMethod(args); // return value is not assigned.Note that if I assign the result of the call to ns1.stringify to an otherwise unused local variable, I get the exact same result but with no build warning.
Chad Killingsworth
> email to closure-compiler-d...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/closure-compiler-discuss/dd815f58-3f25-4c51-b7d7-66bf8210ac7e%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/closure-compiler-discuss/f824a0fe-afda-4e28-a8c8-4ac52a7700ca%40googlegroups.com.--
---
You received this message because you are subscribed to a topic in the Google Groups "Closure Compiler Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/closure-compiler-discuss/ZH08VeWjTHo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to closure-compiler-d...@googlegroups.com.
Chad Killingsworth | Banno | Senior Software Engineer
Jack Henry & Associates, Inc.
To view this discussion on the web visit https://groups.google.com/d/msgid/closure-compiler-discuss/CAK0AWfRAdBjx3mU_UQicveWBbpyQt4B_VfNO3c2157et_6KCLw%40mail.gmail.com.