From d35f0dea8711872e309ea88c7865c23a30d17737 Mon Sep 17 00:00:00 2001 From: Pavel Zverev <31499197+blitz-1306@users.noreply.github.com> Date: Thu, 7 Dec 2023 01:29:45 +0500 Subject: [PATCH] Fix precedence of equality operators for custom operators (#238) (#239) --- src/compile/inference/file_level_definitions.pegjs | 6 +++--- .../inference/file_level_definitions_parser.spec.ts | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/compile/inference/file_level_definitions.pegjs b/src/compile/inference/file_level_definitions.pegjs index d210ad10..4ad13c7b 100644 --- a/src/compile/inference/file_level_definitions.pegjs +++ b/src/compile/inference/file_level_definitions.pegjs @@ -194,10 +194,10 @@ CustomizableOperator = / '%' / '==' / '!=' - / '<' / '<=' - / '>' - / '>='; + / '>=' + / '<' + / '>'; UsingEntry = name: (IdentifierPath) operator: (__ AS __ CustomizableOperator)? { diff --git a/test/unit/compile/inference/file_level_definitions_parser.spec.ts b/test/unit/compile/inference/file_level_definitions_parser.spec.ts index b164638b..ba3dac55 100644 --- a/test/unit/compile/inference/file_level_definitions_parser.spec.ts +++ b/test/unit/compile/inference/file_level_definitions_parser.spec.ts @@ -552,7 +552,7 @@ is /*3*/ int24/*;*/;`, ], [ "using-for custamizable operators", - `using {op.RedLib.toScore, op.RedLib.exp, op.addRed as +, op.mulRed as *, op.unsubRed as -} for Red global;`, + `using {op.RedLib.toScore, op.RedLib.exp, op.addRed as +, op.mulRed as *, op.unsubRed as -, op.lteRed as <=, op.gteRed as >=} for Red global;`, [ { kind: "usingForDirective", @@ -572,6 +572,14 @@ is /*3*/ int24/*;*/;`, { operator: "-", name: "op.unsubRed" + }, + { + operator: "<=", + name: "op.lteRed" + }, + { + operator: ">=", + name: "op.gteRed" } ] }