From 01e6eec97aa73955394a1699224e3a09d8d77eff Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 2 Mar 2022 14:30:55 -0500 Subject: [PATCH] Fix warning about block and default value Ruby's Array#fetch accepts either a default value or a block, but not both. If both are passed in, then it uses the block and outputs this warning: ``` lib/liquid/static_registers.rb:34: warning: block supersedes default value argument ``` --- lib/liquid/static_registers.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/liquid/static_registers.rb b/lib/liquid/static_registers.rb index 0293f5f9..4512c724 100644 --- a/lib/liquid/static_registers.rb +++ b/lib/liquid/static_registers.rb @@ -31,7 +31,11 @@ module Liquid if @registers.key?(key) @registers.fetch(key) elsif default != UNDEFINED - @static.fetch(key, default, &block) + if block_given? + @static.fetch(key, &block) + else + @static.fetch(key, default) + end else @static.fetch(key, &block) end