mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 02:40:41 -07:00
Fix leaking error when comparison leads to TypeError
This commit is contained in:
@@ -113,7 +113,7 @@ module Liquid
|
|||||||
elsif left.respond_to?(operation) && right.respond_to?(operation)
|
elsif left.respond_to?(operation) && right.respond_to?(operation)
|
||||||
begin
|
begin
|
||||||
left.send(operation, right)
|
left.send(operation, right)
|
||||||
rescue ::ArgumentError => e
|
rescue ::ArgumentError, TypeError => e
|
||||||
raise Liquid::ArgumentError.new(e.message)
|
raise Liquid::ArgumentError.new(e.message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ class ConditionUnitTest < Minitest::Test
|
|||||||
assert_evaluates_argument_error 1, '~~', 0
|
assert_evaluates_argument_error 1, '~~', 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_comparing_hash_and_integer
|
||||||
|
assert_evaluates_argument_error({a: 1}, '>', 1)
|
||||||
|
assert_evaluates_argument_error(1, '>', {a: 1})
|
||||||
|
end
|
||||||
|
|
||||||
def test_comparation_of_int_and_str
|
def test_comparation_of_int_and_str
|
||||||
assert_evaluates_argument_error '1', '>', 0
|
assert_evaluates_argument_error '1', '>', 0
|
||||||
assert_evaluates_argument_error '1', '<', 0
|
assert_evaluates_argument_error '1', '<', 0
|
||||||
|
|||||||
Reference in New Issue
Block a user