Skip to content

Conversation

@Shawermik
Copy link
Collaborator

При сравнении числа с булево, выдавало ошибку т.к. tonumber не мог привести его к числу. Добавил проверки на типы, преобразование булева в число и обратно. Исключил арифметические операции с булево и сравнения с строковым типом.

При сравнении числа с булево, выдавало ошибку т.к. tonumber не мог привести его к числу.
Добавил проверки на типы, преобразование булева в число и обратно.
Исключил арифметические операции с булево и сравнения с строковым типом.
@Shawermik Shawermik force-pushed the fix-type-conversion branch from 5c53414 to 311502d Compare January 21, 2026 13:43
jsonpath.lua Outdated
return nil, err
end
if operator == '+' then
if is_bool(op1) or is_bool(op2) then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Предложу заменить условие в этих арифметических операциях на "op1 и op2 должны быть строкой или числом", то есть не запретить булевы значения, а разрешить только числа и строки.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Готово

jsonpath.lua Outdated
-- null must never be equal to other boolean, invert op1
return not op1
else
if type(op2) == 'string' then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Переименовать match_type в match_cmp_type, так как эта функция используется только для приведения типов при операциях сравнения.
  2. Можно добавить из нее второй результат с ошибкой, чтобы сигнализировать о том, что операнды не сравнимы.
  3. После пункта 2 перенести в нее логику гарда (is_null or is_bool) -> false через выдачу ошибки

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

готово

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants