diff --git a/src/parser/expression.js b/src/parser/expression.js index 16e297147b..adeb0e5d50 100644 --- a/src/parser/expression.js +++ b/src/parser/expression.js @@ -979,6 +979,8 @@ pp.parseIdentifier = function (liberal) { this.raise(node.start, "invalid use of await inside of an async function"); } + node.loc.identifierName = node.name; + this.next(); return this.finishNode(node, "Identifier"); }; diff --git a/test/fixtures/core/categorized/identifier-name-loc/actual.js b/test/fixtures/core/categorized/identifier-name-loc/actual.js new file mode 100644 index 0000000000..743fbcb9ed --- /dev/null +++ b/test/fixtures/core/categorized/identifier-name-loc/actual.js @@ -0,0 +1 @@ +foo(bar); diff --git a/test/fixtures/core/categorized/identifier-name-loc/expected.json b/test/fixtures/core/categorized/identifier-name-loc/expected.json new file mode 100644 index 0000000000..3254546650 --- /dev/null +++ b/test/fixtures/core/categorized/identifier-name-loc/expected.json @@ -0,0 +1,100 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "callee": { + "type": "Identifier", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [ + { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "bar" + }, + "name": "bar" + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file