Skip to content

False Positive "Variable Assigned but Not Used" in Style Tags #465

@thagxt

Description

@thagxt

Description:

Theme check is incorrectly identifying variables assigned or captured within a {% liquid %} tag as assigned but not used. This occurs even though the variables are then used with echo withinstyle .

Steps to Reproduce:

  1. Create a Liquid template file.
  2. Inside a style {% liquid %} tag:
    • Assign a variable using {% assign shopName = shop.name %}.
    • Capture content using {% capture example %} and echo 'Shopify' {% endcapture %}.
    • Use echo to output the captured content (echo example) and the assigned variable (echo shopName).
  3. Run the linter or theme check.

Expected Behavior:

The linter should not report any errors for the assigned or captured variables since they are used within the style tag.

Actual Behavior:

The linter flags an error message stating "The variable is assigned but not used."

Source Code:

{%- liquid
                              
assign shopName = shop.name

capture example
  echo 'Shopify'
endcapture
                            
 style
  echo example
  echo shopName
endstyle
-%}

Additional Information:

  • OS: Mac
  • OS Version: Latest
  • Theme Check Version: Latest

Additional context
Screenshot 2024-08-04 at 12 49 56

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingSeverity: 3lowest severity for theme related bug

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions