From b213b879c00515ab6674600f3fbac52e33728248 Mon Sep 17 00:00:00 2001 From: Alex Rattray Date: Sun, 28 May 2017 12:35:37 -0700 Subject: [PATCH] Better error message for anonymous class declarations --- src/parser/statement.js | 2 +- test/fixtures/es2015/uncategorised/263/options.json | 4 ++-- .../esprima/invalid-syntax/migrated_0261/options.json | 4 ++-- .../esprima/invalid-syntax/migrated_0262/options.json | 4 ++-- .../esprima/invalid-syntax/migrated_0263/options.json | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/parser/statement.js b/src/parser/statement.js index d26ca4d1f8..32a682f389 100644 --- a/src/parser/statement.js +++ b/src/parser/statement.js @@ -906,7 +906,7 @@ pp.parseClassId = function (node, isStatement, optionalId) { if (optionalId || !isStatement) { node.id = null; } else { - this.unexpected(); + this.unexpected(null, "A class name is required"); } } }; diff --git a/test/fixtures/es2015/uncategorised/263/options.json b/test/fixtures/es2015/uncategorised/263/options.json index 515b971673..2b34d4c1e1 100644 --- a/test/fixtures/es2015/uncategorised/263/options.json +++ b/test/fixtures/es2015/uncategorised/263/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:6)" -} \ No newline at end of file + "throws": "A class name is required (1:6)" +} diff --git a/test/fixtures/esprima/invalid-syntax/migrated_0261/options.json b/test/fixtures/esprima/invalid-syntax/migrated_0261/options.json index 0ab445fe47..ffd3a3ed26 100644 --- a/test/fixtures/esprima/invalid-syntax/migrated_0261/options.json +++ b/test/fixtures/esprima/invalid-syntax/migrated_0261/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:5)" -} \ No newline at end of file + "throws": "A class name is required (1:5)" +} diff --git a/test/fixtures/esprima/invalid-syntax/migrated_0262/options.json b/test/fixtures/esprima/invalid-syntax/migrated_0262/options.json index 0ab445fe47..ffd3a3ed26 100644 --- a/test/fixtures/esprima/invalid-syntax/migrated_0262/options.json +++ b/test/fixtures/esprima/invalid-syntax/migrated_0262/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:5)" -} \ No newline at end of file + "throws": "A class name is required (1:5)" +} diff --git a/test/fixtures/esprima/invalid-syntax/migrated_0263/options.json b/test/fixtures/esprima/invalid-syntax/migrated_0263/options.json index 0ab445fe47..ffd3a3ed26 100644 --- a/test/fixtures/esprima/invalid-syntax/migrated_0263/options.json +++ b/test/fixtures/esprima/invalid-syntax/migrated_0263/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:5)" -} \ No newline at end of file + "throws": "A class name is required (1:5)" +}