Alex Lam S.L
6cd580dc23
fix parsing of property access after new line ( #1944 )
...
Account for comments when detecting property access in `tokenizer`.
fixes #1943
2017-05-16 06:34:10 +08:00
Alex Lam S.L
ecb63ad8bc
improve keyword-related parser errors ( #1941 )
...
fixes #1937
2017-05-16 06:33:57 +08:00
Alex Lam S.L
24967b8be8
fix & improve coverage of estree ( #1935 )
...
- fix `estree` conversion of getter/setter
- fix non-directive literal in `to_mozilla_ast()`
- revamp `test/mozilla-ast.js`
- reuse `test/ufuzz.js` for code generation
- use `acorn.parse()` for creating `estree`
- extend `test/ufuzz.js` for `acorn` workaround
- catch variable redefinition
- non-trivial literal as directive
- adjust options for tolerance
Miscellaneous
- optional semi-colon when parsing directives
fixes #1914
closes #1915
2017-05-15 18:33:43 +08:00
Alex Lam S.L
a8c67ea353
fix bugs with getter/setter ( #1926 )
...
- `reduce_vars`
- `side_effects`
- property access for object
- `AST_SymbolAccessor` as key names
enhance `test/ufuzz.js`
- add object getter & setter
- property assignment to setter
- avoid infinite recursion in setter
- fix & adjust assignment operators
- 50% `=`
- 25% `+=`
- 2.5% each for the rest
- avoid "Invalid array length"
- fix `console.log()`
- bypass getter
- curb recursive reference
- deprecate `-E`, always report runtime errors
2017-05-15 18:22:43 +08:00
Alex Lam S.L
4027a0c962
fix parser bugs & CLI reporting ( #1827 )
...
fixes #1825
2017-05-15 18:18:04 +08:00
Alex Lam S.L
a0c3836ba0
sort options in alphabetical order ( #1743 )
...
They started off as functional groups I guess, but given the sheer number of options this is becoming too difficult to read.
2017-03-31 16:41:04 +08:00
Alex Lam S.L
2e0dc97003
improve error marker placement ( #1644 )
...
For AST_UnaryPrefix, points to the operator rather than end of expression.
2017-03-24 14:28:40 +08:00
kzc
79334dda10
fix regression: CLI options with hyphens like -b ascii-only ( #1640 )
...
fixes #1637
2017-03-24 11:55:03 +08:00
Alex Lam S.L
4bceb85cbf
throw parse error on invalid assignments ( #1627 )
...
fixes #1626
2017-03-21 14:11:32 +08:00
Alex Lam S.L
cf45e2f79b
fixup for #1585 ( #1589 )
...
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.
2017-03-10 10:49:41 +08:00
Michael Mior
93cdb194f4
Correctly raise a parse exception with a missing loop body ( #1585 )
2017-03-10 03:08:43 +08:00
Alex Lam S.L
eb98a7f2f3
fix handling of shebang and preamble ( #1545 )
...
fixes #1332
2017-03-05 12:16:02 +08:00
Alex Lam S.L
872270b149
improve error messages ( #1506 )
...
- better inheritance of `Error` sub-classes
- mark parse error against source in CLI
closes #235
closes #348
closes #524
closes #1356
closes #1405
2017-02-27 03:40:54 +08:00
Ondřej Španěl
d48a3080ac
Fix: AST_Accessor missing start / end tokens
...
fixes #1492
closes #1493
2017-02-21 13:32:16 +08:00
Anthony Van de Gejuchte
642273c290
Legacy octal integer strict mode fixes
2016-07-21 14:42:16 +02:00
Anthony Van de Gejuchte
2d8af8947e
Fix error style for regex errors
2016-07-15 13:14:30 +02:00
Anthony Van de Gejuchte
a97690fc72
Various LineTerminator changes
...
* Escaped newlines should also produce SyntaxError
* Fix multiline comment parsing and add tests
* Adapt makePredicate to handle \u2028 and \u2029
* Move up nlb check in regex so it's checked before any escape handling
* Change error messages to conform ecma standard
* Find_eol not recornizing \u2028 and \u2029 as line terminator
* Remove \u180e as it is removed in unicode 6.3.0 from the category zs
2016-06-30 22:12:50 +02:00
Anthony Van de Gejuchte
3a7d53f3cf
Move OctalEscapeSequence to read_escape_char
...
This should simplify and improve implementation, make it easier to
implement template strings, and keep master a bit more in sync with
harmony.
Previous implementation wasn't broken, though the loop gave me the
impression it could read infinite numbers and annoyed me a bit. It was
also slightly unnecessary because the lookup involved only 3 characters.
2016-06-30 21:42:15 +02:00
Anthony Van de Gejuchte
6c99816855
Normalize error messages
2016-06-19 21:08:34 +02:00
Anthony Van de Gejuchte
2149bfb707
Don't mix strings with directives in output
...
* Don't interpret strings with escaped content as directive
* Don't interpret strings after empty statement as directive
* Adapt output to prevent strings being represent as directive
* Introduce UGLIFY_DEBUG to allow internal testing like EXPECT_DIRECTIVE
2016-06-19 20:59:17 +02:00
Anthony Van de Gejuchte
bb9c9707aa
Don't allow with statements in strict mode
2016-06-12 19:08:16 +02:00
Anthony Van de Gejuchte
4d7746baf3
Throw errors in strict mode for octal strings
...
Adds a directive tracker for the parser/tokenizer to
allow parsing depending on directive context.
2016-06-12 14:27:08 +02:00
Anthony Van de Gejuchte
00ad57e393
Do not allow newlines in regex
2016-06-05 17:02:19 +02:00
kzc
f39fd3d583
Handle CR line endings in comments.
...
Fixes #1050
2016-05-04 20:02:29 +02:00
kzc
e4fa4b109a
Parse comments without recursion to avoid RangeError.
...
Fixes #993
2016-04-16 02:02:47 -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
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
Anthony Van de Gejuchte
6f3e35bb3f
Fix ch that could contain other newline characters
2015-12-27 22:24:37 +01:00
Anthony Van de Gejuchte
174404c0f3
Do not allow newlines in string literals
2015-12-26 15:08:37 +01:00
Anthony Van de Gejuchte
bd99b00413
Semicolon after do...while statement is optional
2015-12-17 23:02:35 +01:00
Mihai Bazon
08623aa6a7
Fix output for "use asm" code from SpiderMonkey AST
...
(will only work properly if the SM tree contains "raw" properties for
Literal number nodes)
2015-11-12 12:18:25 +02:00
Mihai Bazon
7691bebea5
Rework has_directive
...
It's now available during tree walking, i.e. walker.has_directive("use
asm"), rather than as part of the scope. It's thus no longer necessary
to call `figure_out_scope` before codegen. Added special bits in the
code generator to overcome the fact that it doesn't inherit from
TreeWalker.
Fix #861
2015-11-11 22:15:25 +02:00
Mihai Bazon
18d37ac761
Fix parsing invalid input
...
i.e. `x = 1.xe` — because parseFloat("1.xe") returns 1, this parsed as
`x = 1`.
Ref #857
2015-11-09 13:15:20 +02:00
Richard van Velzen
63d35f8f6d
Prevent ReDoS by not using a regexp to verify floating point numbers
...
`parseFloat` will return `NaN` for invalid numbers anyway, which is the check used to throw the parse error.
Fixes #857
2015-11-09 11:28:27 +01:00
kzc
4d2f7d83af
Fix handling of "use asm" when no command line flags are passed to uglifyjs. SCOPE_IS_NEEDED is unconditionally true now. Refactored floating point literal parsing to be more in keeping with the AST class design.
2015-10-07 13:10:53 -04:00
kzc
593677d2ff
Add proper support for "use asm"; blocks. Disable -c optimization within "use asm"; sections and preserve floating point literals in their original form. Non-asm.js sections are optimized as before. Asm.js sections can still be mangled and minified of whitespace. No special command line flags are required.
2015-10-07 10:00:28 +02:00
Anthony Van de Gejuchte
c69294c449
Implement shebang support
2015-10-06 22:35:45 +02:00
Richard van Velzen
fcde6109b0
Fix bad parsing of new new x()() constructs
...
Fixes #739
2015-08-27 12:29:36 +03:00
Chris Cowan
9854deb626
Re-use the caught exception's error message in the parse error call.
2015-07-29 15:06:52 +02:00
Chris Cowan
d6814050dd
Give a good error message if an invalid regular expression is found.
2015-07-29 15:05:59 +02:00
Mihai Bazon
bce4307e9e
Treat \uFEFF as whitespace.
...
Fix #714
2015-05-20 16:17:46 +03:00
Mihai Bazon
e637bdaf4e
Only drop the BOM when it's the first character.
...
Close #704
2015-05-05 10:11:38 +03:00
Mihai Bazon
92e4340732
Fix parsing strings with literal DOS newlines
...
(should not set newline_before)
Fix #693
2015-04-23 12:08:19 +03:00
Mihai Bazon
d36faffeca
Fix parsing for U+2028 / U+2029
...
(they should be treated as whitespace)
2015-03-18 10:09:30 +02:00
Edward Casbon
ae07714927
Add filename to the JS_Parse_Error exception.
...
It would be nice to have access to the filename of the file that includes the code that causes a JavaScript error. This is especially handy if uglifying multiple files at once.
Only a small change is needed for this to happen as it's already available in the function that throws the error.
2015-02-11 23:21:22 +01:00
Mihai Bazon
fbbaa42ee5
Add option to preserve/enforce string quote style
...
`-q 0` (default) use single or double quotes such as to minimize the number of
bytes (prefers double quotes when both will do); this is the previous
behavior.
`-q 1` -- always use single quotes
`-q 2` -- always use double quotes
`-q 3` or just `-q` -- always use the original quotes.
Related codegen option: `quote_style`.
Close #495
Close #460
Some `yargs` guru please tell me why `uglifyjs --help` doesn't display the
help string for `-q` / `--quotes`, and why it doesn't output the expected
argument types anymore, like good old `optimist` did.
2015-01-27 22:26:27 +02:00
Anthony Van de Gejuchte
74cda80d3b
Add unicode digit parsing support
2015-01-20 00:17:24 +01:00
Anthony Van de Gejuchte
9a3a848cc8
Update unicode letter
2015-01-20 00:17:03 +01:00
Ingvar Stepanyan
ae5366a31d
Track ending lines/columns; fix end locations in Mozilla AST.
2015-01-06 11:32:41 +01:00
Mihai Bazon
13219cebcb
Fix handling \r\n
...
Close #437
2015-01-05 12:14:42 +02:00