- allow immediate assignment after declaration of variable
- relax modification rule for immutable value
- fix order of visit for TreeWalker
- remove extraneous code
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`.
- fix side effects in switch condition for singular blocks
- fix `undefined` confusion with local variable
- gate `OPT(AST_Switch)` with `switches`
fixes#1758fixes#1759
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.
That particular version of Node.js has messed up error messages, so provide a version-specific workaround.
Also fixed an formatting issue which would cause `expect_stdout` to fail if error message contains excerpts of input.
Apply `expect_stdout` to more applicable tests.
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
- one-use function call => IIFE should take `eval()` & `arguments` into account
- if unused parameter cannot be eliminated, replace it with `0`
fixes#1583
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#1573fixes#1575
`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.
Avoid variable substitution in the following cases:
- use of variable before declaration
- declaration within conditional code blocks
- declaration within loop body
fixes#1518fixes#1525
- remove call to evaluate() in is_constant() and let nested optimize() does its job instead
- reject RegExp in is_constant() and remove special case logic under collapse_vars
- operands to conditionals optimisation are now always evaluate()-ed
- throw error in constant_value() instead of returning undefined to catch possible bugs, similar to make_node_from_constant()
- optimise binary boolean operators under `evaluate` instead of `conditionals`