diff --git a/lib/runtime.js b/lib/runtime.js index 45aec3d..e45394e 100644 --- a/lib/runtime.js +++ b/lib/runtime.js @@ -93,7 +93,10 @@ PEG.Parser.prototype = { this._rightmostMatchFailuresPos = this._pos; this._rightmostMatchFailuresExpected = []; } - this._rightmostMatchFailuresExpected.push(failure); + + if (this._rightmostMatchFailuresExpected.indexOf(failure) === -1) { + this._rightmostMatchFailuresExpected.push(failure); + } }, /* diff --git a/test/compiler-test.js b/test/compiler-test.js index 59922ce..0d05ddc 100644 --- a/test/compiler-test.js +++ b/test/compiler-test.js @@ -456,6 +456,13 @@ test("error messages", function() { "something", 'Expected end of input but "s" found.' ); + + var duplicateErrorParser = PEG.buildParser('start: "a" / "a"'); + doesNotParseWithMessage( + duplicateErrorParser, + "", + 'Expected "a" but end of input found.' + ); }); test("error positions", function() {