Shopify / Shopify/liquid

Deprecate variableLookups on LHS of assign.

Open
#1,603 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
11.9k
Forks
1.5k
Avg merge
17h 55m
Merged PRs (30d)
3

Description

This is obscure and we do support it but behaves rather strangely. We should deprecate this.

{% assign product.img = "hi" %}

{% # prints nothing %}
{{ product.img }}

{% # prints "hi" %}
{{ ["product.img"] }}

It's because we parse the entire assign LHS as a string and then assign the context's <stringValueOfLHS> to be the value of the RHS. And our VariableSegment regex accepts dots and square brackets.

https://github.com/Shopify/liquid/blob/81f44e36be5f2110c26b6532fd4ccd22edaf59f2/lib/liquid/tags/assign.rb#L38

https://github.com/Shopify/liquid/blob/81f44e36be5f2110c26b6532fd4ccd22edaf59f2/lib/liquid/tags/assign.rb#L17

https://github.com/Shopify/liquid/blob/81f44e36be5f2110c26b6532fd4ccd22edaf59f2/lib/liquid.rb#L33

While we're there, we should probably cleanup our regex for variable segment, variable signature, etc.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/liquid/tags/assign.rb and the referenced variable parsing code in lib/liquid.rb. Trace how the assign LHS becomes a context string value, then review the VariableSegment and variable signature regexes. Done means the current LHS lookup behavior is deprecated and the related regex handling is cleaned up without preserving the confusing semantics.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
compilers
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.