Skip to content

Commit

Permalink
parser: Fix Hack/smart-pipe error positions (#13426)
Browse files Browse the repository at this point in the history
  • Loading branch information
js-choi authored and nicolo-ribaudo committed Aug 3, 2021
1 parent 6276853 commit cd4b3fb
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions packages/babel-parser/src/parser/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ export default class ExpressionParser extends LValParser {
if (pipeProposal) {
// A pipe-operator proposal is active.

const tokenType = this.state.type;
const { type: tokenType, start } = this.state;

if (this.testTopicReferenceConfiguration(pipeProposal, tokenType)) {
// The token matches the plugin鈥檚 configuration.
Expand Down Expand Up @@ -1295,18 +1295,18 @@ export default class ExpressionParser extends LValParser {
// it is outside of a pipe body.
// Raise recoverable errors.
if (pipeProposal === "smart") {
this.raise(this.state.start, Errors.PrimaryTopicNotAllowed);
this.raise(start, Errors.PrimaryTopicNotAllowed);
} else {
// In this case, `pipeProposal === "hack"` is true.
this.raise(this.state.start, Errors.PipeTopicUnbound);
this.raise(start, Errors.PipeTopicUnbound);
}
}

return this.finishNode(node, nodeType);
} else {
// The token does not match the plugin鈥檚 configuration.
throw this.raise(
this.state.start,
start,
Errors.PipeTopicUnconfiguredToken,
tokenType.label,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}},
"errors": [
"SyntaxError: Topic reference is unbound; it must be inside a pipe body. (1:5)"
"SyntaxError: Topic reference is unbound; it must be inside a pipe body. (1:4)"
],
"program": {
"type": "Program",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":130,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":2}},
"errors": [
"SyntaxError: Topic reference was used in a lexical context without topic binding. (6:15)",
"SyntaxError: Topic reference was used in a lexical context without topic binding. (6:13)",
"SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)"
],
"program": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":3}},
"errors": [
"SyntaxError: Topic reference was used in a lexical context without topic binding. (5:13)",
"SyntaxError: Topic reference was used in a lexical context without topic binding. (5:11)",
"SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)"
],
"program": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
"errors": [
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:40)",
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:39)",
"SyntaxError: Pipeline is in topic style but does not use topic reference. (1:5)"
],
"program": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":42}},
"errors": [
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:23)",
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:22)",
"SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)"
],
"program": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":77,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: Topic reference was used in a lexical context without topic binding. (2:49)",
"SyntaxError: Topic reference was used in a lexical context without topic binding. (2:48)",
"SyntaxError: Pipeline is in topic style but does not use topic reference. (2:11)"
],
"program": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}},
"errors": [
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:46)",
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:45)",
"SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)"
],
"program": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}},
"errors": [
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:33)",
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:32)",
"SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)"
],
"program": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
"errors": [
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:35)",
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:34)",
"SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)"
],
"program": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":78,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
"errors": [
"SyntaxError: Topic reference was used in a lexical context without topic binding. (3:33)"
"SyntaxError: Topic reference was used in a lexical context without topic binding. (3:32)"
],
"program": {
"type": "Program",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
"errors": [
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:35)",
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:34)",
"SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)"
],
"program": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}},
"errors": [
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:25)",
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:24)",
"SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)"
],
"program": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}},
"errors": [
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:21)",
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:19)",
"SyntaxError: Pipeline is in topic style but does not use topic reference. (1:5)"
],
"program": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}},
"errors": [
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:21)",
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:19)",
"SyntaxError: Pipeline is in topic style but does not use topic reference. (1:5)"
],
"program": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "File",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}},
"errors": [
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:5)"
"SyntaxError: Topic reference was used in a lexical context without topic binding. (1:4)"
],
"program": {
"type": "Program",
Expand Down

0 comments on commit cd4b3fb

Please sign in to comment.