Repository: Shopify/liquid (Ruby)

Issue:
undefined method `to_liquid' for :auto_ids:Symbol
Heya friends!

We're all upgraded to Liquid 4 which is CRAZY COOL and I wanted to check in on something. I saw an error recently which is a `NoMethodError`:

```text
undefined method `to_liquid' for :auto_ids:Symbol
```

It seems like `Symbol` should have a `to_liquid` method?

<details>
<pre>/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/variable_lookup.rb:49:in `block in evaluate'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/variable_lookup.rb:38:in `each_index'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/variable_lookup.rb:38:in `evaluate'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/context.rb:159:in `evaluate'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/variable.rb:106:in `block in evaluate_filter_expressions'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/variable.rb:106:in `map'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/variable.rb:106:in `evaluate_filter_expressions'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/variable.rb:77:in `block in render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/variable.rb:76:in `each'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/variable.rb:76:in `inject'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/variable.rb:76:in `render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/assign.rb:24:in `render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:109:in `render_node'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:88:in `block in render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:75:in `each'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:75:in `render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/for.rb:158:in `block (2 levels) in render_segment'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/for.rb:156:in `each'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/for.rb:156:in `each_with_index'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/for.rb:156:in `block in render_segment'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/context.rb:123:in `stack'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/for.rb:148:in `render_segment'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/for.rb:77:in `render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:109:in `render_node'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:88:in `block in render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:75:in `each'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:75:in `render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/if.rb:44:in `block (2 levels) in render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/if.rb:42:in `each'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/if.rb:42:in `block in render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/context.rb:123:in `stack'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/if.rb:41:in `render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:109:in `render_node'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:88:in `block in render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:75:in `each'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:75:in `render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/if.rb:44:in `block (2 levels) in render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/if.rb:42:in `each'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/if.rb:42:in `block in render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/context.rb:123:in `stack'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/if.rb:41:in `render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:109:in `render_node'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:88:in `block in render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:75:in `each'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:75:in `render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/for.rb:158:in `block (2 levels) in render_segment'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/for.rb:156:in `each'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/for.rb:156:in `each_with_index'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/for.rb:156:in `block in render_segment'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/context.rb:123:in `stack'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/for.rb:148:in `render_segment'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/tags/for.rb:77:in `render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:109:in `render_node'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:88:in `block in render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:75:in `each'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:75:in `render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/template.rb:208:in `block in render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/template.rb:242:in `with_profiling'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/template.rb:207:in `render'
/home/user/.bundle/ruby/2.4.0/gems/liquid-4.0.0/lib/liquid/template.rb:220:in `render!'
/home/user/.bundle/ruby/2.4.0/gems/jekyll-3.5.2/lib/jekyll/liquid_renderer/file.rb:28:in `block (2 levels) in render!'</pre>
</details>

What do you think? /cc @fw42 @pushrax @dylanahsmith 


Discussion:
I wonder how we haven't run into this before, would make sense to support.
A user was iterating through their jekyll config and there was a symbol key in the config. When they did `{{ the_key }}`, it exploded. 

If it's simple to fix, I can submit a PR! Anything interesting in the pipeline for a Liquid 4.0.1 or 4.1.0?
I encountered the same error, maybe it causes my github pages not update.
What do you suggest `to_liquid` should do in this case?
Probably return self, like all the other default implementations.
Sounds reasonable to me
💗 



Patch:
diff --git a/lib/liquid/extensions.rb b/lib/liquid/extensions.rb
index d35bcea8d..090781930 100644
--- a/lib/liquid/extensions.rb
+++ b/lib/liquid/extensions.rb
@@ -7,6 +7,12 @@ def to_liquid
   end
 end
 
+class Symbol # :nodoc:
+  def to_liquid
+    to_s
+  end
+end
+
 class Array # :nodoc:
   def to_liquid
     self


Test patch:
diff --git a/test/integration/variable_test.rb b/test/integration/variable_test.rb
index 58df83385..abd6e70c6 100644
--- a/test/integration/variable_test.rb
+++ b/test/integration/variable_test.rb
@@ -89,4 +89,8 @@ def test_hash_with_default_proc
   def test_multiline_variable
     assert_equal 'worked', Template.parse("{{\ntest\n}}").render!('test' => 'worked')
   end
+
+  def test_render_symbol
+    assert_template_result 'bar', '{{ foo }}', 'foo' => :bar
+  end
 end