Opened 14 years ago

Closed 13 years ago

Last modified 13 years ago

#5303 closed defect (duplicate)

shrinksafe runtime reference error

Reported by: guest Owned by: alex
Priority: high Milestone: future
Component: ShrinkSafe Version: 1.0
Keywords: Cc: [email protected]
Blocked By: Blocking:

Description (last modified by bill)

Shrinksafe generates bad code when compressing a certain file.

Version info




JS Code

[email protected]:/tmp/js$ cat bad.js 
(function() {
    CallMe = function(callback) {

    var say_hello_twice = function() {


    var say_hello = function() {
        print('hello world');



The code works uncompressed and when compressed with yuicompressor, but not when compressed with Shrinksafe:

[email protected]:/tmp/js$ java -jar js.jar -f bad.js
hello world
hello world

[email protected]:/tmp/js$ java -jar custom_rhino.jar -c bad.js | java -jar js.jar -f -
Rhino 1.6 release 7 2007 08 19
js> js: "<stdin>", line 21: uncaught JavaScript runtime exception: ReferenceError: "say_hello" is not defined.
js> js> 

[email protected]:/tmp/js$ java -jar yuicompressor-2.2.5.jar bad.js | java -jar js.jar -f -

[INFO] Using charset UTF-8
Rhino 1.6 release 7 2007 08 19
js> hello world
hello world

The difference is that yuicompressor renamed both references to say_hello, while Shrinksafe only renamed one:

[email protected]:/tmp/js$ java -jar custom_rhino.jar -c bad.js
var _2=function(){
var _3=function(){
print("hello world");

[email protected]:/tmp/js$ java -jar yuicompressor-2.2.5.jar bad.js

[INFO] Using charset UTF-8
(function(){CallMe=function(C){C()};var B=function(){A();CallMe(function(){A()})};var A=function(){print("hello world")};B()})()


Change History (6)

comment:1 Changed 14 years ago by dylan

Milestone: 1.3

comment:2 Changed 13 years ago by bill

Description: modified (diff)
Milestone: 1.3future

move unowned / abandoned tickets to "future" milestone

comment:3 Changed 13 years ago by Adam Peller

Resolution: duplicate
Status: newclosed

this example works as of trunk 2009-01-26, probably as a result of upgrading to Rhino 1.7 (see #7127)

I believe this is a dup of #3241

comment:4 Changed 13 years ago by Adam Peller

(In [16542]) Create Shrinksafe unit tests. Refs #5303

comment:5 Changed 13 years ago by Adam Peller

(In [16543]) Refactor shrinksafe unit test. Refs #5303

comment:6 Changed 13 years ago by Adam Peller

(In [16909]) restructure and improve existing shrinksafe test. Refs #5303

Note: See TracTickets for help on using tickets.