Skip to content

WIP5 - #169

Draft
charlespwd wants to merge 1 commit into
liquid-factory-shared-expressions-in-forfrom
liquid-factory-array-literals
Draft

WIP5#169
charlespwd wants to merge 1 commit into
liquid-factory-shared-expressions-in-forfrom
liquid-factory-array-literals

Conversation

@charlespwd

@charlespwd charlespwd commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Research / WIP
Experimental output from liquid-factory, shared for design and code feedback. This is a research draft for the WIP3 stack, not a merge-ready language change.

In this PR

Add conformance cases for native array literals, with existing Array consumers as the compatibility reference.

Problem

The parent parser rejects a leading [ in templates. Adding constructors needs explicit expected results and fixed expectations for existing successful rendering.

Solution

The cases cover construction, nesting, trailing commas, expression-valued elements and the existing expression-taking consumers. Preservation expectations come from the pinned parent; new literal results use the approved contract and equivalent environment-Array results.

Paired implementation: Shopify/liquid#2134, on the shared-for stack.

Ruby API migration

Remove reject_bare_brackets: from Parser.new calls. The shared parser now has one leading-bracket grammar, including in Context#[]:

  • context['[key]'] evaluates an array containing the value of key.
  • Use context['self[key]'] for the indirect variable lookup previously expressed by bare brackets.

Existing native-template results stay unchanged. Typed legacy lookup-string APIs remain separate; this change does not add a replacement parser mode.

Feature boundary

Outcome

Construct an Array directly with [] or [expression, ...] wherever the native parser accepts an expression.

Scope

  • Empty, nested and expression-valued arrays, whitespace and one optional trailing comma at each level.
  • Ordinary Array behavior in output, filters, conditions, case/when, loops, cycle, assignment and lookups on assigned variables.
  • Existing expression-taking tag positions, including render/include arguments, use the shared grammar.
  • Literal-owned containers are fresh on each evaluation. Element values retain their existing semantics.
  • Existing native-template output stays unchanged. The shared Parser and Context#[] now use the same array grammar for leading brackets; self[...] remains explicit lookup.

Acceptance boundary

  • The paired specs/liquid_ruby/array_literals.yml contains the approved preservation, constructor and malformed-input cases.
  • Existing native-template indexed/dotted/self lookup results, WIP3 expression semantics and shared-for metadata/modifiers remain unchanged.
  • The exact render/include examples and inherited assignment-score/resource limits are covered in test/integration/array_literal_test.rb.
  • Malformed arrays, key-value elements and direct postfix access such as [1, 2][0] remain syntax errors.

Non-goals

Hash literals, mixed array/hash literal nesting, arithmetic, filtered parentheses, interpolation, new postfix grammar and changes to for-argument separators.

Dependencies

  • Parent implementation: Shopify/liquid#2133, liquid-factory-shared-expressions-in-for at 372f77cbebd9c9c5319d967a1a988d7c5878b225.
  • Parent specs: Shopify/liquid-spec#168, the same branch name at 736ebca7b4377dbd8bf59232649fa00c69b21ea3.
  • These dependencies are present at the pinned bases. This pair is stacked on those branches, not on main or the independent hash-literal feature.

The cases are examples, not proof that every possible template preserves its output.

@charlespwd charlespwd mentioned this pull request Oct 27, 2026
@charlespwd charlespwd changed the title WIP: Array literals (specs) WIP5 Oct 27, 2026

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