Skip to content

UndefinedObject: don't report continue in a for loop offset - #1364

Open
barrymcgee wants to merge 1 commit into
Shopify:mainfrom
barrymcgee:barry/undefined-object-offset-continue
Open

barrymcgee wants to merge 1 commit into
Shopify:mainfrom
barrymcgee:barry/undefined-object-offset-continue

Conversation

@barrymcgee

Copy link
Copy Markdown

What are you adding in this PR?

UndefinedObject no longer reports continue in {% for ... offset: continue %}.

In a for tag, offset: continue is a Liquid keyword. It starts the loop where the last loop over the same collection stopped. The check read continue as a variable lookup and reported:

UndefinedObject: Unknown object 'continue' used.

Dawn, Craft and Sense hit this in their own code, in sections/main-product.liquid:

{% for product in recommendations.products limit: n offset: continue %}

The check now skips continue only when all of these are true:

  • It has no lookups (continue, not continue.size).
  • It is the value of the offset: argument.
  • The tag is for. Ruby Liquid supports offset: continue only in for, so tablerow is still reported.

{{ continue }}, limit: continue, offset: continue.size and tablerow ... offset: continue are still reported.

What's next? Any followup issues?

None for this check. Dawn has a separate PR for its other Theme Check warnings.

Tophatting

  • New spec: the offset: continue cases are not reported. This spec fails without the fix.
  • New spec: the four cases above are still reported.
  • All 48 tests in undefined-object/index.spec.ts pass. Prettier is clean.
  • A local build of theme-check-node with this change no longer reports continue on Dawn main.
  • Also checked by hand: the {% liquid %} tag form and for ... reversed offset: continue are not reported.

Before you deploy

  • I included a patch bump changeset

{% for x in y offset: continue %} resumes a loop where the previous loop over the same collection stopped. continue is a keyword there, but the check read it as a variable lookup and reported "Unknown object 'continue' used." Dawn, Craft and Sense all hit this in sections/main-product.liquid. Only for supports it, so tablerow, other arguments and continue.<property> are still reported.
@barrymcgee
barrymcgee marked this pull request as ready for review October 22, 2026 11:38
@barrymcgee
barrymcgee requested a review from a team as a code owner October 22, 2026 11:38

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant