Add location to the "Rule ... is already defined" error message

See this discussion:

  eb5875bc6a (commitcomment-17970220)
redux
David Majda 8 years ago
parent f9bc0fe619
commit 2a889535bd

@ -11,12 +11,14 @@ function reportDuplicateRules(ast) {
rule: function(node) {
if (rules.hasOwnProperty(node.name)) {
throw new GrammarError(
"Rule \"" + node.name + "\" is already defined.",
"Rule \"" + node.name + "\" is already defined "
+ "at line " + rules[node.name].start.line + ", "
+ "column " + rules[node.name].start.column + ".",
node.location
);
}
rules[node.name] = true;
rules[node.name] = node.location;
}
});

@ -10,7 +10,7 @@ describe("compiler pass |reportDuplicateRules|", function() {
'start = "a"',
'start = "b"'
].join('\n'), {
message: 'Rule "start" is already defined.',
message: 'Rule "start" is already defined at line 1, column 1.',
location: {
start: { offset: 12, line: 2, column: 1 },
end: { offset: 23, line: 2, column: 12 }

Loading…
Cancel
Save