Age | Commit message (Collapse) | Author |
|
fixes #1698
|
|
`statement_to_expression()` drops `typeof` even if it operates on undeclared variables.
Since we now have `drop_side_effect_free()`, replace and remove this deprecated functionality.
|
|
fixes #1690
|
|
Unlike normal variables and even function definitions, these cannot be reassigned, even though assignment expressions would "leak" the assigned value as normal.
|
|
Process variable definitions with or without assigned values against:
- `arguments`
- named function arguments
- multiple definitions within same scope
Essentially demote variable declarations with no value assignments.
Also fixed invalid use of `AST_VarDef` over `arguments` - should use a member of `AST_SymbolDeclaration` instead.
|
|
|
|
Conditions including strict mode would make `delete` return `true` or `false`, and are too complex to be evaluated by the compressor.
Suppress assignment folding into said operator.
fixes #1685
|
|
- de-duplicate trailing cases only, avoid all potential side-effects
- enable switch statement fuzzing
fixes #1680
|
|
|
|
fixes #1679
|
|
extension of #1675
|
|
- correctly determine reachability of (default) branches
- gracefully handle multiple default branches
- optimise branches with duplicate bodies
fixes #376
fixes #441
fixes #1674
|
|
`AST_Try` is an `AST_Block`, so besides try block we also need to inspect catch and finally blocks for possible side effects.
Also extend this functionality to handle `AST_If` and `AST_LabeledStatement` while we are at it.
fixes #1673
|
|
Take conditional nature of switch branches into account.
fixes #1670
|
|
`has_side_effects()` does not take `typeof`'s magical power of not tripping over undeclared variable into account.
fixes #1668
|
|
Need to call `extract_declarations_from_unreachable_code()`.
fixes #1663
|
|
Turns out the only place in `Compressor` which can generate invalid `AST_For.init` is within `drop_unused()`, so focus the fix-up efforts.
supercedes #1652
fixes #1656
|
|
Operator has changed, so break out from rest of the rules.
fixes #1649
|
|
Enforce `null` as value for empty initialisation blocks.
fixes #1648
|
|
fixes #1645
fixes #1646
|
|
take side effects of binary boolean operations into account
fixes #1639
|
|
For AST_UnaryPrefix, points to the operator rather than end of expression.
|
|
fixes #1637
|
|
- #1634 bars variables with cross-scope references in between to collapse
- but if assigned value is side-effect-free, no states can be modified, so it is safe to move
|
|
mostly done by @kzc
fixes #1631
|
|
report the following only when `options.warnings = "verbose"`
- unused elements due to inlining
- collpased variables
|
|
fixes #1626
|
|
The following is wrong:
`a == (b ? a : c)` => `b`
Because:
- `b` may not be boolean
- `a` might have side effects
- `a == a` is not always `true` (think `NaN`)
- `a == c` is not always `false`
|
|
Commit eab99a1c fails to account for side effects from compound assignments.
|
|
Guarded by `unsafe` as `charAt()` can be overridden.
|
|
`reduce_vars` enables substitution of variables but did not clone the value's `AST_Node`.
This confuses `collapse_vars` and result in invalid AST and subsequent crash.
fixes #1609
|
|
fixes #1605
|
|
`hoist_vars` converts variable declarations into plain assignments, which then confuses `reduce_vars`
fixes #1606
|
|
As patched in #1597, `make_node_from_constant()` makes inconsistent and sometimes incorrect calls to `optimize()` and `transform()`.
Fix those issues properly by changing the semantics of `evaluate()` and `make_node_from_constant()`, with the side effect that `evaluate()` no longer eagerly converts constant to `AST_Node`.
|
|
Liberal use of `Compressor.transform()` and `AST_Node.optimize()` presents an issue for look-up operations like `TreeWalker.in_boolean_context()` and `TreeWalker.parent()`.
This is an incremental fix such that `AST_Node.optimize()` would now contain the correct stack information when called correctly.
|
|
- remove obsolete optimisation in `AST_Binary` after #1477
- improve `TreeWalker.has_directive()` readability and resilience against multiple visits
|
|
fixes #1592
|
|
Self-referenced function has non-fixed values assigned to its parameters.
Let `unused` & `!keep_fnames` do the scanning, then apply `reduce_vars` only to unnamed functions.
fixes #1595
|
|
As patched on `harmony`, `statement()` is the only user of `embed_tokens()` with a missing error branch.
Updated test case and match up with `harmony` to facilitate future merging.
|
|
`AST_Scope.def_variable()` will overwrite `AST_Symbol.thedef`, so save a copy before calling.
fixes #1586
|
|
|
|
- one-use function call => IIFE should take `eval()` & `arguments` into account
- if unused parameter cannot be eliminated, replace it with `0`
fixes #1583
|
|
- similar case as #1578 but against #1450 instead
- fix `this` binding in #1450 as well
closes #1580
|
|
those were not optimised for `unused` before, which made it necessary for `reduce_vars` to have separate steps for `keep_fnames`
docs update by @kzc
closes #1577
|
|
Function expression can be assigned to a variable and be given a name. Ensure function name is the reduced variable before clearing it out.
fixes #1573
fixes #1575
|
|
- omitting trailing semi-colon in do-while breaks non-browser parser, e.g. uglify-js 1.x
- trailing semi-colon only breaks IE8 if followed by `else` or `while`
- always use braces in do-while body to workaround 2nd case with no size loss in compression
fixes #1568
|
|
`side-effects` did not account for IIFEs being able to reference itself thus making its return value potentially significant
|
|
`AST_Label.references` get `.initialize()` to `[]` every time after `.clone()`
So walk down the tree to pick up the cloned `AST_LoopControl` pieces and put it back together.
|
|
- expose function body to call sites for potential optimisations
- suppress substitution of variable used within `AST_Defun`
|
|
- unless `toplevel` is enabled
- global `const` works as before
|