Improved catch handling in `figure_out_scope()` means special case treatment of IE8 is no longer valid in `reset_opt_flags()`.
Also fixed recursive assignment in variable definition.
`AST_Node.optimize()` is context-aware, so don't cache its results to be used elsewhere.
Also fixed a few cases of AST corruption and beef up safety of `pure_getters`.
- property access to `null` & `undefined` always has side effects
- utilise `reduce_vars` to determine safe property access
- may-be cases treated as side effects unless `unsafe`
Although it would be nice to enforce `AST_Node` cloning during transformation, that ship has sailed a long time ago.
We now get the assigned value when resolving `AST_SymbolRef` instead of `reset_opt_flags()`, which has the added advantage of improved compressor efficiency.
fixes#1787
- fix side effects in switch condition for singular blocks
- fix `undefined` confusion with local variable
- gate `OPT(AST_Switch)` with `switches`
fixes#1758fixes#1759
- `side_effects` will clean up inner statements, so checking for an empty function body should suffice
- drop side effects when dropping `return` from statement
- move these optimisations out from `Compressor` to `OutputStream`
- fixes behaviour inconsistency when running uglified code from global or module levels due to redefinition
When fixing catch-related issue in #1715, it tries to optimise for duplicate definitions but did not take anonymous functions into account.
Remove such optimisation for now and we can cover this as a more general rule later.
`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.
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
`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