Open
Conversation
При сравнении числа с булево, выдавало ошибку т.к. tonumber не мог привести его к числу. Добавил проверки на типы, преобразование булева в число и обратно. Исключил арифметические операции с булево и сравнения с строковым типом.
5c53414 to
311502d
Compare
potemin1999
reviewed
Jan 22, 2026
jsonpath.lua
Outdated
| return nil, err | ||
| end | ||
| if operator == '+' then | ||
| if is_bool(op1) or is_bool(op2) then |
Collaborator
There was a problem hiding this comment.
Предложу заменить условие в этих арифметических операциях на "op1 и op2 должны быть строкой или числом", то есть не запретить булевы значения, а разрешить только числа и строки.
jsonpath.lua
Outdated
| -- null must never be equal to other boolean, invert op1 | ||
| return not op1 | ||
| else | ||
| if type(op2) == 'string' then |
Collaborator
There was a problem hiding this comment.
- Переименовать match_type в match_cmp_type, так как эта функция используется только для приведения типов при операциях сравнения.
- Можно добавить из нее второй результат с ошибкой, чтобы сигнализировать о том, что операнды не сравнимы.
- После пункта 2 перенести в нее логику гарда (is_null or is_bool) -> false через выдачу ошибки
alrsorokin
reviewed
Feb 2, 2026
jsonpath.lua
Outdated
|
|
||
| -- Helper helper: match type of second operand to type of first operand | ||
| local function match_type(op1, op2) | ||
| local function match_cmp_type(op1, op2, compare) |
Collaborator
There was a problem hiding this comment.
отступ не поехал случайно?
jsonpath.lua
Outdated
| if operator == '+' then | ||
| op1 = tonumber(op1) + tonumber(op2) | ||
| if is_str_or_int(op1) and is_str_or_int(op2) then | ||
| op1 = tonumber(op1) + tonumber(op2) |
Collaborator
There was a problem hiding this comment.
падаждите, оно же взорвется если:
op1 = "a"
op2 = "b"
Collaborator
Author
There was a problem hiding this comment.
Согласен, поправил
alrsorokin
approved these changes
Feb 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
При сравнении числа с булево, выдавало ошибку т.к. tonumber не мог привести его к числу. Добавил проверки на типы, преобразование булева в число и обратно. Исключил арифметические операции с булево и сравнения с строковым типом.