Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Old) uglfiy-js hangs forever #35

Closed
truongsinh opened this issue Dec 9, 2012 · 3 comments
Closed

(Old) uglfiy-js hangs forever #35

truongsinh opened this issue Dec 9, 2012 · 3 comments

Comments

@truongsinh
Copy link

uglfiy-js (1.0.7) fails to process the following code (taken from jinjs):

function parse_BINARY_OPERATOR() {
    var cacheKey = 'BINARY_OPERATOR@' + pos;
    var cachedResult = cache[cacheKey];
    if (cachedResult) {
        pos = cachedResult.nextPos;
        return cachedResult.result;
    }

    if (input.substr(pos, 3) === ">>>") {
        var result28 = ">>>";
        pos += 3;
    } else {
        var result28 = null;
        if (reportMatchFailures) {
            matchFailed("\">>>\"");
        }
    }
    if (result28 !== null) {
        var result0 = result28;
    } else {
        if (input.substr(pos, 3) === "===") {
            var result27 = "===";
            pos += 3;
        } else {
            var result27 = null;
            if (reportMatchFailures) {
                matchFailed("\"===\"");
            }
        }
        if (result27 !== null) {
            var result0 = result27;
        } else {
            if (input.substr(pos, 3) === "!==") {
                var result26 = "!==";
                pos += 3;
            } else {
                var result26 = null;
                if (reportMatchFailures) {
                    matchFailed("\"!==\"");
                }
            }
            if (result26 !== null) {
                var result0 = result26;
            } else {
                if (input.substr(pos, 2) === "==") {
                    var result25 = "==";
                    pos += 2;
                } else {
                    var result25 = null;
                    if (reportMatchFailures) {
                        matchFailed("\"==\"");
                    }
                }
                if (result25 !== null) {
                    var result0 = result25;
                } else {
                    if (input.substr(pos, 2) === "!=") {
                        var result24 = "!=";
                        pos += 2;
                    } else {
                        var result24 = null;
                        if (reportMatchFailures) {
                            matchFailed("\"!=\"");
                        }
                    }
                    if (result24 !== null) {
                        var result0 = result24;
                    } else {
                        if (input.substr(pos, 2) === ">=") {
                            var result23 = ">=";
                            pos += 2;
                        } else {
                            var result23 = null;
                            if (reportMatchFailures) {
                                matchFailed("\">=\"");
                            }
                        }
                        if (result23 !== null) {
                            var result0 = result23;
                        } else {
                            if (input.substr(pos, 2) === "<=") {
                                var result22 = "<=";
                                pos += 2;
                            } else {
                                var result22 = null;
                                if (reportMatchFailures) {
                                    matchFailed("\"<=\"");
                                }
                            }
                            if (result22 !== null) {
                                var result0 = result22;
                            } else {
                                if (input.substr(pos, 2) === "&&") {
                                    var result21 = "&&";
                                    pos += 2;
                                } else {
                                    var result21 = null;
                                    if (reportMatchFailures) {
                                        matchFailed("\"&&\"");
                                    }
                                }
                                if (result21 !== null) {
                                    var result0 = result21;
                                } else {
                                    if (input.substr(pos, 2) === "||") {
                                        var result20 = "||";
                                        pos += 2;
                                    } else {
                                        var result20 = null;
                                        if (reportMatchFailures) {
                                            matchFailed("\"||\"");
                                        }
                                    }
                                    if (result20 !== null) {
                                        var result0 = result20;
                                    } else {
                                        if (input.substr(pos, 2) === "<<") {
                                            var result19 = "<<";
                                            pos += 2;
                                        } else {
                                            var result19 = null;
                                            if (reportMatchFailures) {
                                                matchFailed("\"<<\"");
                                            }
                                        }
                                        if (result19 !== null) {
                                            var result0 = result19;
                                        } else {
                                            if (input.substr(pos, 2) === ">>") {
                                                var result18 = ">>";
                                                pos += 2;
                                            } else {
                                                var result18 = null;
                                                if (reportMatchFailures) {
                                                    matchFailed("\">>\"");
                                                }
                                            }
                                            if (result18 !== null) {
                                                var result0 = result18;
                                            } else {
                                                if (input.substr(pos, 2) === "+=") {
                                                    var result17 = "+=";
                                                    pos += 2;
                                                } else {
                                                    var result17 = null;
                                                    if (reportMatchFailures) {
                                                        matchFailed("\"+=\"");
                                                    }
                                                }
                                                if (result17 !== null) {
                                                    var result0 = result17;
                                                } else {
                                                    if (input.substr(pos, 2) === "-=") {
                                                        var result16 = "-=";
                                                        pos += 2;
                                                    } else {
                                                        var result16 = null;
                                                        if (reportMatchFailures) {
                                                            matchFailed("\"-=\"");
                                                        }
                                                    }
                                                    if (result16 !== null) {
                                                        var result0 = result16;
                                                    } else {
                                                        if (input.substr(pos, 2) === "%=") {
                                                            var result15 = "%=";
                                                            pos += 2;
                                                        } else {
                                                            var result15 = null;
                                                            if (reportMatchFailures) {
                                                                matchFailed("\"%=\"");
                                                            }
                                                        }
                                                        if (result15 !== null) {
                                                            var result0 = result15;
                                                        } else {
                                                            if (input.substr(pos, 2) === "/=") {
                                                                var result14 = "/=";
                                                                pos += 2;
                                                            } else {
                                                                var result14 = null;
                                                                if (reportMatchFailures) {
                                                                    matchFailed("\"/=\"");
                                                                }
                                                            }
                                                            if (result14 !== null) {
                                                                var result0 = result14;
                                                            } else {
                                                                if (input.substr(pos, 2) === "*=") {
                                                                    var result13 = "*=";
                                                                    pos += 2;
                                                                } else {
                                                                    var result13 = null;
                                                                    if (reportMatchFailures) {
                                                                        matchFailed("\"*=\"");
                                                                    }
                                                                }
                                                                if (result13 !== null) {
                                                                    var result0 = result13;
                                                                } else {
                                                                    if (input.substr(pos, 1) === "=") {
                                                                        var result12 = "=";
                                                                        pos += 1;
                                                                    } else {
                                                                        var result12 = null;
                                                                        if (reportMatchFailures) {
                                                                            matchFailed("\"=\"");
                                                                        }
                                                                    }
                                                                    if (result12 !== null) {
                                                                        var result0 = result12;
                                                                    } else {
                                                                        if (input.substr(pos, 1) === "|") {
                                                                            var result11 = "|";
                                                                            pos += 1;
                                                                        } else {
                                                                            var result11 = null;
                                                                            if (reportMatchFailures) {
                                                                                matchFailed("\"|\"");
                                                                            }
                                                                        }
                                                                        if (result11 !== null) {
                                                                            var result0 = result11;
                                                                        } else {
                                                                            if (input.substr(pos, 1) === "/") {
                                                                                var result10 = "/";
                                                                                pos += 1;
                                                                            } else {
                                                                                var result10 = null;
                                                                                if (reportMatchFailures) {
                                                                                    matchFailed("\"/\"");
                                                                                }
                                                                            }
                                                                            if (result10 !== null) {
                                                                                var result0 = result10;
                                                                            } else {
                                                                                if (input.substr(pos, 1) === "^") {
                                                                                    var result9 = "^";
                                                                                    pos += 1;
                                                                                } else {
                                                                                    var result9 = null;
                                                                                    if (reportMatchFailures) {
                                                                                        matchFailed("\"^\"");
                                                                                    }
                                                                                }
                                                                                if (result9 !== null) {
                                                                                    var result0 = result9;
                                                                                } else {
                                                                                    if (input.substr(pos, 1) === "&") {
                                                                                        var result8 = "&";
                                                                                        pos += 1;
                                                                                    } else {
                                                                                        var result8 = null;
                                                                                        if (reportMatchFailures) {
                                                                                            matchFailed("\"&\"");
                                                                                        }
                                                                                    }
                                                                                    if (result8 !== null) {
                                                                                        var result0 = result8;
                                                                                    } else {
                                                                                        if (input.substr(pos, 1) === "|") {
                                                                                            var result7 = "|";
                                                                                            pos += 1;
                                                                                        } else {
                                                                                            var result7 = null;
                                                                                            if (reportMatchFailures) {
                                                                                                matchFailed("\"|\"");
                                                                                            }
                                                                                        }
                                                                                        if (result7 !== null) {
                                                                                            var result0 = result7;
                                                                                        } else {
                                                                                            if (input.substr(pos, 1) === "+") {
                                                                                                var result6 = "+";
                                                                                                pos += 1;
                                                                                            } else {
                                                                                                var result6 = null;
                                                                                                if (reportMatchFailures) {
                                                                                                    matchFailed("\"+\"");
                                                                                                }
                                                                                            }
                                                                                            if (result6 !== null) {
                                                                                                var result0 = result6;
                                                                                            } else {
                                                                                                if (input.substr(pos, 1) === ">") {
                                                                                                    var result5 = ">";
                                                                                                    pos += 1;
                                                                                                } else {
                                                                                                    var result5 = null;
                                                                                                    if (reportMatchFailures) {
                                                                                                        matchFailed("\">\"");
                                                                                                    }
                                                                                                }
                                                                                                if (result5 !== null) {
                                                                                                    var result0 = result5;
                                                                                                } else {
                                                                                                    if (input.substr(pos, 1) === "<") {
                                                                                                        var result4 = "<";
                                                                                                        pos += 1;
                                                                                                    } else {
                                                                                                        var result4 = null;
                                                                                                        if (reportMatchFailures) {
                                                                                                            matchFailed("\"<\"");
                                                                                                        }
                                                                                                    }
                                                                                                    if (result4 !== null) {
                                                                                                        var result0 = result4;
                                                                                                    } else {
                                                                                                        if (input.substr(pos, 1) === "%") {
                                                                                                            var result3 = "%";
                                                                                                            pos += 1;
                                                                                                        } else {
                                                                                                            var result3 = null;
                                                                                                            if (reportMatchFailures) {
                                                                                                                matchFailed("\"%\"");
                                                                                                            }
                                                                                                        }
                                                                                                        if (result3 !== null) {
                                                                                                            var result0 = result3;
                                                                                                        } else {
                                                                                                            if (input.substr(pos, 1) === "-") {
                                                                                                                var result2 = "-";
                                                                                                                pos += 1;
                                                                                                            } else {
                                                                                                                var result2 = null;
                                                                                                                if (reportMatchFailures) {
                                                                                                                    matchFailed("\"-\"");
                                                                                                                }
                                                                                                            }
                                                                                                            if (result2 !== null) {
                                                                                                                var result0 = result2;
                                                                                                            } else {
                                                                                                                if (input.substr(pos, 1) === "*") {
                                                                                                                    var result1 = "*";
                                                                                                                    pos += 1;
                                                                                                                } else {
                                                                                                                    var result1 = null;
                                                                                                                    if (reportMatchFailures) {
                                                                                                                        matchFailed("\"*\"");
                                                                                                                    }
                                                                                                                }
                                                                                                                if (result1 !== null) {
                                                                                                                    var result0 = result1;
                                                                                                                } else {
                                                                                                                    var result0 = null;
                                                                                                                    ;
                                                                                                                };
                                                                                                            };
                                                                                                        };
                                                                                                    };
                                                                                                };
                                                                                            };
                                                                                        };
                                                                                    };
                                                                                };
                                                                            };
                                                                        };
                                                                    };
                                                                };
                                                            };
                                                        };
                                                    };
                                                };
                                            };
                                        };
                                    };
                                };
                            };
                        };
                    };
                };
            };
        };
    }
    return result0;
}
@truongsinh
Copy link
Author

I solved this problem by updating uglify-js to 1.3.4
Note: Latest 1.x version from github is 1.3.7, which is not available from npm repo. Latest version 2.x causes API break, something like "parse of undefined"

truongsinh added a commit to truongsinh/snockets that referenced this issue Dec 9, 2012
…com/TrevorBurnham/snockets/issues/35 . Note: Latest 1.x version from github is 1.3.7, which is not available from npm repo. Latest version 2.x causes API break, something like "parse of undefined"
@pthrasher
Copy link
Owner

I've updated to 2.0 on HEAD along with some other changes. Snockets 2.0 is still a WIP, I expect to have this done by the end of the month.

@pthrasher
Copy link
Owner

fixed in #43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants