Skip to content

uses_arguments always false since commit 6605d15783 #1299

@thejh

Description

@thejh

Hi!

At the moment, uses_arguments doesn't work properly:

$ node -e 'var uglify = require("."); var ast = uglify.parse("function f(){arguments}"); ast.figure_out_scope(); process.exit(ast.body[0].uses_arguments ? 0 : 1)'
$ echo $?
1

git blame says the bug was introduced in commit 6605d15:

$ git bisect start master v2.5.0
Bisecting: 89 revisions left to test after this (roughly 7 steps)
[f68de86a174530a1e796eabbf872633a01485900] Merge pull request #1011 from kzc/dont-produce-let-in-mangle
$ git bisect run node -e 'var uglify = require("."); var ast = uglify.parse("function f(){arguments}"); ast.figure_out_scope(); process.exit(ast.body[0].uses_arguments ? 0 : 1)'
running node -e var uglify = require("."); var ast = uglify.parse("function f(){arguments}"); ast.figure_out_scope(); process.exit(ast.body[0].uses_arguments ? 0 : 1)
Bisecting: 44 revisions left to test after this (roughly 6 steps)
[88b77ddaa9d6b3d55e537dc21030ac58ddfcb86e] Add test case for line continuation
running node -e var uglify = require("."); var ast = uglify.parse("function f(){arguments}"); ast.figure_out_scope(); process.exit(ast.body[0].uses_arguments ? 0 : 1)
Bisecting: 22 revisions left to test after this (roughly 5 steps)
[00c8d1d24149e4172ce9ddd237e4c7620a1346d3] collapse_vars: document option in README
running node -e var uglify = require("."); var ast = uglify.parse("function f(){arguments}"); ast.figure_out_scope(); process.exit(ast.body[0].uses_arguments ? 0 : 1)
Bisecting: 10 revisions left to test after this (roughly 4 steps)
[1b703349cf824020c4dc64a58aa6d0dc3b809cea] Tighten up @const regex.
running node -e var uglify = require("."); var ast = uglify.parse("function f(){arguments}"); ast.figure_out_scope(); process.exit(ast.body[0].uses_arguments ? 0 : 1)
Bisecting: 4 revisions left to test after this (roughly 3 steps)
[57e0fafd5c35552fb1ea63c829a7f6ea7000b6f8] Merge pull request #918 from avdg/fix-arguments-handling
running node -e var uglify = require("."); var ast = uglify.parse("function f(){arguments}"); ast.figure_out_scope(); process.exit(ast.body[0].uses_arguments ? 0 : 1)
Bisecting: 2 revisions left to test after this (roughly 2 steps)
[6605d1578351939ee0e39a13bf68cc9c1708c918] Never mangle arguments and keep them in their scope
running node -e var uglify = require("."); var ast = uglify.parse("function f(){arguments}"); ast.figure_out_scope(); process.exit(ast.body[0].uses_arguments ? 0 : 1)
Bisecting: 0 revisions left to test after this (roughly 1 step)
[ac8db977b95b447cba577b41285cb0fa9e65ebdd] Merge pull request #905 from avdg/unit-tests
running node -e var uglify = require("."); var ast = uglify.parse("function f(){arguments}"); ast.figure_out_scope(); process.exit(ast.body[0].uses_arguments ? 0 : 1)
6605d1578351939ee0e39a13bf68cc9c1708c918 is the first bad commit
commit 6605d1578351939ee0e39a13bf68cc9c1708c918
Author: Anthony Van de Gejuchte <anthonyvdgent@gmail.com>
Date:   Sun Jan 10 23:33:54 2016 +0100

    Never mangle arguments and keep them in their scope

    Fixes #892

    Helped-by: kzc

:040000 040000 2c7e3bd55af862e00e11cd13b1534b8c66980514 2dd46bb2db3ab789e4b799eea73f7c33111f7cb4 M  lib
:040000 040000 6c317359b733d1715247fe156ee930ba13d9b755 2604ae8278ac4f4451ea9b2f453df376662e5201 M  test
bisect run success
$ git bisect reset
Previous HEAD position was ac8db97... Merge pull request #905 from avdg/unit-tests
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.

I think the issue is that commit 6605d15 pretends that an arguments variable was already found, causing if (func && name == "arguments") to never be reached because sym is already true-ish.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions