Commit Graph

695 Commits

Author SHA1 Message Date
Richard van Velzen 8571a08a93 Do not attempt evaluating class expressions
Broadly the same as function expressions - these actually are statements but
we're limited by the inheritance tree.

Fixes #1044
2016-04-19 20:01:26 +02:00
Richard van Velzen 68cc14f846 Fixups after merge 2016-04-18 15:51:32 +02:00
Richard van Velzen f94497d1d6 Merge branch 'master' into harmony 2016-04-18 15:50:35 +02:00
kzc e4fa4b109a Parse comments without recursion to avoid RangeError.
Fixes #993
2016-04-16 02:02:47 -04:00
Richard van Velzen 4b4528ee05 Prevent endless recursion when evaluating self-referencing consts
Fix #1041
2016-04-13 15:03:31 +02:00
Richard van Velzen eaf3911c31 Consider yield expressions as having side-effects
See #1043
2016-04-13 14:39:49 +02:00
Darío Javier Cravero 91cdb93e57 Implement harmony generators and yield
Uses #716's implementation and adds tests.

Fixes #716.
2016-04-13 14:22:08 +02:00
Mihai Bazon b5a7a231f7 Actually limit sequence length.
Fix #1038
2016-04-12 14:17:24 +03:00
kzc 3907a5e3b2 Fix warnings for referenced non-hoisted functions.
Fixes #1034

Also added `expect_warnings` functionality to test framework.
2016-04-11 18:15:20 +02:00
kzc c70d176f35 Simplify member(name, array) implementation. 2016-04-07 09:57:30 -04:00
Mihai Bazon 9317237372 Avoid using inherited hasOwnProperty
Fix #1031
2016-04-07 13:16:22 +03:00
kzc 98434258d0 Optimize ternaries with boolean consequent or alternative.
Fixes #511
2016-04-02 17:22:12 +02:00
kzc 45ddb9caeb Speedup unused compress option for already minified code
Fixes: #321 #917 #1022
2016-03-28 17:58:50 -04:00
Fábio Santos 634f231b78 First class block scope
- Make let, const, and class symbols be declared in a block scope.
- Piggy back on existing catch symbol implementation to get block-aware mangling working
- Make sure unused block-scoped declarations can be dropped
- Don't eliminate a block if it has a block-scoped declaration
- Remove silly empty anonymous blocks left over from drop_unused
- AST_Toplevel now gets to call drop_unused too, since block-scoped variables aren't global!
- Don't consider block declarations global
2016-03-27 19:40:20 +02:00
Fábio Santos 6702cae918 fix #1021 2016-03-27 12:21:39 +01:00
Mihai Bazon f68de86a17 Merge pull request #1011 from kzc/dont-produce-let-in-mangle
Do not produce `let` as a variable name in mangle.
2016-03-24 18:16:26 +02:00
kzc 07bb7262d0 Escape all ASCII control characters within strings when using ascii_only.
Fixes #1017.

Tab characters within strings are now output as `\t` in all output modes.
2016-03-24 11:51:54 -04:00
kzc a9d4a6291b Do not produce let as a variable name in mangle.
Would previously occur in large generated functions with 21,000+ variables.
Fixes #986.
2016-03-15 11:20:32 -04:00
Fábio Santos 6d2f77c180 fix #1003 by removing AST_ObjectSymbol and using AST_ObjectKeyVal for the same effect 2016-03-14 13:42:50 +01:00
Fábio Santos accca2445f fix crash: Import statements don't abort 2016-03-14 12:54:05 +01:00
Fábio Santos 0bc4f6edb4 Don't mangle exported symbols 2016-03-14 12:54:05 +01:00
Fábio Santos ce84a706a3 Implement the export statement 2016-03-14 12:54:05 +01:00
Fábio Santos 86b5248837 Mangling externally imported names by using aliasing 2016-03-14 12:54:05 +01:00
Fábio Santos 59e1601fb8 importing names in the modules, not just default imports 2016-03-14 12:54:05 +01:00
Fábio Santos d35a9e7839 Importing names from places 2016-03-14 12:54:05 +01:00
Fábio Santos 0465bd270d Starting out the import statement 2016-03-14 12:54:05 +01:00
philippsimon ee6c9fabb7 Fix: Uglified Number.prototype functions on big numbers 2016-03-14 12:41:06 +01:00
viclm 6780d0906c Fix eager parsing of arrow functions for non-punc tokens 2016-03-10 22:18:48 +01:00
kzc 102d1b9137 #877 Ignore mangle sort option 2016-02-27 15:33:10 -05:00
kzc 11b0efdf84 boolean_expression ? true : false --> boolean_expression 2016-02-22 17:59:36 +01:00
kzc 5486b68850 Take operator || precendence into account for AST_If optimization.
Fixes #979.
2016-02-21 12:05:02 -05:00
alexlamsl 6547437725 preserve ThisBinding for side_effects 2016-02-17 19:34:01 +01:00
Richard van Velzen 9662228f6a Don't compress (0, eval)() to eval() 2016-02-16 19:00:48 +01:00
alexlamsl 31a9b05c96 Preserve ThisBinding in conditionals & collapse_vars
Fixes #973
2016-02-16 18:47:49 +01:00
sergeyv 7a4ed9d200 Revert "using the original sourcemap as the base"
This reverts commit ad18689d92.

Reason for revert: introduce issue #882

Currently, generated sourcemap contains copy of all existing mappings and adds new mappings from uglified code to original one.
However, previous mapping are no longer valid and shouldn't be added.
2016-02-10 10:19:39 +01:00
Darío Javier Cravero 0b303379c0 fix: don't fail if definition is undefined
Running `uglifyjs --verbose --compress --mangle --screw-ie8 class.js`
with
`class.js`:
```
class Foo {
  bar() {
  }
}
```
Fails with:
```
undefined:4041
  return this.definition().unmangleable(options);
TypeError: Cannot read property 'unmangleable' of undefined
...
```
2016-02-10 10:17:32 +01:00
Fábio Santos d7ec2ecc12 Fix #931: Create arrow functions in maybe_assign so that they can be used in assignments 2016-02-09 00:02:23 +00:00
kzc 7c3fee9e31 collapse_vars: avoid replacement across AST_Case nodes to be on safe side even though no issues seen. 2016-01-29 10:35:07 -05:00
kzc 929de2b0de collapse_vars: fix if/else and ternary operator side effects 2016-01-28 12:17:06 -05:00
kzc af2472d85e collapse_vars: fix bug in repeated var defs of same name 2016-01-28 16:48:50 +01:00
kzc 0a38a688f9 fix bug in collapse_vars for right side of "||" and "&&" 2016-01-27 14:18:46 -05:00
kzc f4c2ea37bf Collapse single use var definitions
Fix #721
2016-01-27 11:48:15 +02:00
Mihai Bazon 915f907186 Add start/end in the arguments definition
(keeps my https://github.com/mishoo/jsinfo.el working)
2016-01-27 11:36:03 +02:00
Richard van Velzen b5a7197ae5 Merge pull request #928 from STRML/constPragma
Mark vars with /** @const */ pragma as consts so they can be eliminated.
2016-01-20 19:04:36 +01:00
Samuel Reed 1b703349cf Tighten up @const regex. 2016-01-20 11:35:45 -06:00
Samuel Reed 4a7179ff91 Simplify by skipping extra tree walk. 2016-01-20 11:03:41 -06:00
Samuel Reed f97da4294a Use TreeWalker for more accurate @const results and update tests 2016-01-20 10:54:00 -06:00
Samuel Reed 8b71c6559b Mark vars with /** @const */ pragma as consts so they can be eliminated.
Fixes older browser support for consts and allows more flexibility
in dead code removal.
2016-01-19 13:23:02 -06:00
Anthony Van de Gejuchte 26641f3fb2 Allow operator names as getters/setters
Fixes #919

Fix provided by @kzc
2016-01-19 19:28:51 +01:00
Fugiman 5e78f20f1c Remove duplicate error message 2016-01-19 19:22:22 +01:00