parser: Fix Hack/smart-pipe error positions (#13426)

This commit is contained in:
J. S. Choi 2021-06-07 10:09:12 -04:00 committed by Nicolò Ribaudo
parent 6276853eb9
commit cd4b3fbffe
16 changed files with 19 additions and 19 deletions

View File

@ -1264,7 +1264,7 @@ export default class ExpressionParser extends LValParser {
if (pipeProposal) { if (pipeProposal) {
// A pipe-operator proposal is active. // A pipe-operator proposal is active.
const tokenType = this.state.type; const { type: tokenType, start } = this.state;
if (this.testTopicReferenceConfiguration(pipeProposal, tokenType)) { if (this.testTopicReferenceConfiguration(pipeProposal, tokenType)) {
// The token matches the plugins configuration. // The token matches the plugins configuration.
@ -1295,10 +1295,10 @@ export default class ExpressionParser extends LValParser {
// it is outside of a pipe body. // it is outside of a pipe body.
// Raise recoverable errors. // Raise recoverable errors.
if (pipeProposal === "smart") { if (pipeProposal === "smart") {
this.raise(this.state.start, Errors.PrimaryTopicNotAllowed); this.raise(start, Errors.PrimaryTopicNotAllowed);
} else { } else {
// In this case, `pipeProposal === "hack"` is true. // In this case, `pipeProposal === "hack"` is true.
this.raise(this.state.start, Errors.PipeTopicUnbound); this.raise(start, Errors.PipeTopicUnbound);
} }
} }
@ -1306,7 +1306,7 @@ export default class ExpressionParser extends LValParser {
} else { } else {
// The token does not match the plugins configuration. // The token does not match the plugins configuration.
throw this.raise( throw this.raise(
this.state.start, start,
Errors.PipeTopicUnconfiguredToken, Errors.PipeTopicUnconfiguredToken,
tokenType.label, tokenType.label,
); );

View File

@ -2,7 +2,7 @@
"type": "File", "type": "File",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}}, "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}},
"errors": [ "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": { "program": {
"type": "Program", "type": "Program",

View File

@ -2,7 +2,7 @@
"type": "File", "type": "File",
"start":0,"end":130,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":2}}, "start":0,"end":130,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":2}},
"errors": [ "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)" "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)"
], ],
"program": { "program": {

View File

@ -2,7 +2,7 @@
"type": "File", "type": "File",
"start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":3}}, "start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":3}},
"errors": [ "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)" "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)"
], ],
"program": { "program": {

View File

@ -2,7 +2,7 @@
"type": "File", "type": "File",
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}}, "start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
"errors": [ "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)" "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:5)"
], ],
"program": { "program": {

View File

@ -2,7 +2,7 @@
"type": "File", "type": "File",
"start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":42}}, "start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":42}},
"errors": [ "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)" "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)"
], ],
"program": { "program": {

View File

@ -2,7 +2,7 @@
"type": "File", "type": "File",
"start":0,"end":77,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "start":0,"end":77,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [ "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)" "SyntaxError: Pipeline is in topic style but does not use topic reference. (2:11)"
], ],
"program": { "program": {

View File

@ -2,7 +2,7 @@
"type": "File", "type": "File",
"start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}}, "start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}},
"errors": [ "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)" "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)"
], ],
"program": { "program": {

View File

@ -2,7 +2,7 @@
"type": "File", "type": "File",
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}}, "start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}},
"errors": [ "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)" "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)"
], ],
"program": { "program": {

View File

@ -2,7 +2,7 @@
"type": "File", "type": "File",
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
"errors": [ "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)" "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)"
], ],
"program": { "program": {

View File

@ -2,7 +2,7 @@
"type": "File", "type": "File",
"start":0,"end":78,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}}, "start":0,"end":78,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
"errors": [ "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": { "program": {
"type": "Program", "type": "Program",

View File

@ -2,7 +2,7 @@
"type": "File", "type": "File",
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
"errors": [ "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)" "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)"
], ],
"program": { "program": {

View File

@ -2,7 +2,7 @@
"type": "File", "type": "File",
"start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}}, "start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}},
"errors": [ "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)" "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)"
], ],
"program": { "program": {

View File

@ -2,7 +2,7 @@
"type": "File", "type": "File",
"start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}}, "start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}},
"errors": [ "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)" "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:5)"
], ],
"program": { "program": {

View File

@ -2,7 +2,7 @@
"type": "File", "type": "File",
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}},
"errors": [ "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)" "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:5)"
], ],
"program": { "program": {

View File

@ -2,7 +2,7 @@
"type": "File", "type": "File",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}}, "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}},
"errors": [ "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": { "program": {
"type": "Program", "type": "Program",