Skip to content

Commit

Permalink
Predicates shouldn't use SILENT_FAILS
Browse files Browse the repository at this point in the history
  • Loading branch information
markw65 committed Dec 12, 2023
1 parent 63b913d commit 11ffe00
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 6 deletions.
2 changes: 0 additions & 2 deletions lib/compiler/passes/generate-bytecode.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,12 @@ function generateBytecode(ast, options) {

return buildSequence(
[op.PUSH_CURR_POS],
[op.SILENT_FAILS_ON],
// eslint-disable-next-line no-use-before-define -- Mutual recursion
generate(expression, {
sp: context.sp + 1,
env: cloneEnv(context.env),
action: null,
}),
[op.SILENT_FAILS_OFF],
buildCondition(
negative ? -match : match,
[negative ? op.IF_ERROR : op.IF_NOT_ERROR],
Expand Down
1 change: 1 addition & 0 deletions test/behavior/generated-parser-behavior.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2183,6 +2183,7 @@ describe("generated parser behavior", () => {
expect(parser).to.failToParse("d", {
expected: [
{ type: "literal", text: "a", ignoreCase: false },
{ type: "literal", text: "b", ignoreCase: false },
{ type: "literal", text: "c", ignoreCase: false },
],
});
Expand Down
4 changes: 0 additions & 4 deletions test/unit/compiler/passes/generate-bytecode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,7 @@ describe("compiler pass |generateBytecode|", () => {
it("generates correct bytecode", () => {
expect(pass).to.changeAST(grammar, bytecodeDetails([
5, // PUSH_CURR_POS
28, // SILENT_FAILS_ON
18, 0, 2, 2, 22, 0, 23, 0, // <expression>
29, // SILENT_FAILS_OFF
15, 3, 3, // IF_NOT_ERROR
6, // * POP
7, // POP_CURR_POS
Expand All @@ -427,9 +425,7 @@ describe("compiler pass |generateBytecode|", () => {
it("generates correct bytecode", () => {
expect(pass).to.changeAST(grammar, bytecodeDetails([
5, // PUSH_CURR_POS
28, // SILENT_FAILS_ON
18, 0, 2, 2, 22, 0, 23, 0, // <expression>
29, // SILENT_FAILS_OFF
14, 3, 3, // IF_ERROR
6, // * POP
6, // POP
Expand Down

0 comments on commit 11ffe00

Please sign in to comment.