From 820f4748754a699c4ae38d701273f6b0d9e008e2 Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Tue, 26 Jul 2016 15:52:29 +0100 Subject: [PATCH] Fix accidental fall-through in Flow type parsing. When parsing a primary type, `>` would erroneously be treated like `(`. --- src/plugins/flow.js | 2 ++ test/fixtures/flow/type-annotations/106/actual.js | 1 + test/fixtures/flow/type-annotations/106/options.json | 3 +++ 3 files changed, 6 insertions(+) create mode 100644 test/fixtures/flow/type-annotations/106/actual.js create mode 100644 test/fixtures/flow/type-annotations/106/options.json diff --git a/src/plugins/flow.js b/src/plugins/flow.js index 7c85da6255..9e6caca3db 100644 --- a/src/plugins/flow.js +++ b/src/plugins/flow.js @@ -505,6 +505,8 @@ pp.flowParsePrimaryType = function () { node.returnType = this.flowParseType(); return this.finishNode(node, "FunctionTypeAnnotation"); + } else { + this.unexpected(); } case tt.parenL: diff --git a/test/fixtures/flow/type-annotations/106/actual.js b/test/fixtures/flow/type-annotations/106/actual.js new file mode 100644 index 0000000000..0a8290512d --- /dev/null +++ b/test/fixtures/flow/type-annotations/106/actual.js @@ -0,0 +1 @@ +var f: >x:int) => string; diff --git a/test/fixtures/flow/type-annotations/106/options.json b/test/fixtures/flow/type-annotations/106/options.json new file mode 100644 index 0000000000..c958665c03 --- /dev/null +++ b/test/fixtures/flow/type-annotations/106/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token (1:7)" +}