aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--lib/parse.js6
-rw-r--r--test/compress/loops.js24
3 files changed, 28 insertions, 4 deletions
diff --git a/README.md b/README.md
index bd0d7c48..67324dbd 100644
--- a/README.md
+++ b/README.md
@@ -783,7 +783,7 @@ The `source_map_options` (optional) can contain the following properties:
came from. It can be simply a string in JSON, or a JSON object containing
the original source map.
- [acorn]: https://github.com/marijnh/acorn
+ [acorn]: https://github.com/ternjs/acorn
[source-map]: https://github.com/mozilla/source-map
[sm-spec]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
[codegen]: http://lisperator.net/uglifyjs/codegen
diff --git a/lib/parse.js b/lib/parse.js
index de27d987..4d06ae05 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -724,9 +724,9 @@ function parse($TEXT, options) {
);
};
- function semicolon() {
+ function semicolon(optional) {
if (is("punc", ";")) next();
- else if (!can_insert_semicolon()) unexpected();
+ else if (!optional && !can_insert_semicolon()) unexpected();
};
function parenthesised() {
@@ -814,7 +814,7 @@ function parse($TEXT, options) {
case "do":
return new AST_Do({
body : in_loop(statement),
- condition : (expect_token("keyword", "while"), tmp = parenthesised(), semicolon(), tmp)
+ condition : (expect_token("keyword", "while"), tmp = parenthesised(), semicolon(true), tmp)
});
case "while":
diff --git a/test/compress/loops.js b/test/compress/loops.js
index cdf1f045..91aa1c5f 100644
--- a/test/compress/loops.js
+++ b/test/compress/loops.js
@@ -121,3 +121,27 @@ drop_if_else_break_4: {
for (; bar() && (x(), y(), foo());) baz(), z(), k();
}
}
+
+parse_do_while_with_semicolon: {
+ options = { loops: false };
+ input: {
+ do {
+ x();
+ } while (false);y()
+ }
+ expect: {
+ do x(); while (false);y();
+ }
+}
+
+parse_do_while_without_semicolon: {
+ options = { loops: false };
+ input: {
+ do {
+ x();
+ } while (false)y()
+ }
+ expect: {
+ do x(); while (false);y();
+ }
+} \ No newline at end of file