Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Not valid identifier" error for a quotes-containing identifier #252

Closed
lancedikson opened this issue Oct 3, 2020 · 1 comment · Fixed by fastify/point-of-view#182
Closed

Comments

@lancedikson
Copy link

lancedikson commented Oct 3, 2020

Hi, I've just encountered a bug in parsing such construction from Shopify templates:

{% capture "form_classes" -%}
            product-form product-form-{{ section.id }}
            {%- unless section.settings.show_variant_labels %} product-form--hide-variant-labels {% endunless %}
            {%- if section.settings.enable_payment_button and product.has_only_default_variant %} product-form--payment-button-no-variants {%- endif -%}
            {%- if current_variant.available == false %} product-form--variant-sold-out {%- endif -%}
{%- endcapture %}

The error stack is:

Thrown:
"form_classes" not valid identifier, line:142, col:11
   140|           {%- endif -%}
   141| 
>> 142|           {% capture "form_classes" -%}
   143|             product-form product-form-{{ section.id }}
   144|             {%- unless section.settings.show_variant_labels %} product-form--hide-variant-labels {% endunless %}
   145|             {%- if section.settings.enable_payment_button and product.has_only_default_variant %} product-form--payment-button-no-variants {%- endif -%}
ParseError: "form_classes" not valid identifier, line:142, col:11
    at Parser.parseToken (/Users/lancedikson/Projects/videoly/shopify-apps/node/videoly-integration-app/node_modules/liquidjs/dist/liquid.node.cjs.js:1647:19)
    at Parser.parse (/Users/lancedikson/Projects/videoly/shopify-apps/node/videoly-integration-app/node_modules/liquidjs/dist/liquid.node.cjs.js:1632:33)
    at Liquid.parse (/Users/lancedikson/Projects/videoly/shopify-apps/node/videoly-integration-app/node_modules/liquidjs/dist/liquid.node.cjs.js:2720:28)
    at repl:1:3
    at Script.runInThisContext (vm.js:123:20)
    at REPLServer.defaultEval (repl.js:384:29)
    at bound (domain.js:415:14)
    at REPLServer.runBound [as eval] (domain.js:428:12)
    at REPLServer.onLine (repl.js:700:10)
    at REPLServer.emit (events.js:205:15)
From AssertionError: "form_classes" not valid identifier
    at assert (/Users/lancedikson/Projects/videoly/shopify-apps/node/videoly-integration-app/node_modules/liquidjs/dist/liquid.node.cjs.js:774:15)
    at Object.parse (/Users/lancedikson/Projects/videoly/shopify-apps/node/videoly-integration-app/node_modules/liquidjs/dist/liquid.node.cjs.js:1774:9)
    at new Tag (/Users/lancedikson/Projects/videoly/shopify-apps/node/videoly-integration-app/node_modules/liquidjs/dist/liquid.node.cjs.js:1549:23)
    at Parser.parseToken (/Users/lancedikson/Projects/videoly/shopify-apps/node/videoly-integration-app/node_modules/liquidjs/dist/liquid.node.cjs.js:1639:24)
    at Parser.parse (/Users/lancedikson/Projects/videoly/shopify-apps/node/videoly-integration-app/node_modules/liquidjs/dist/liquid.node.cjs.js:1632:33)
    at Liquid.parse (/Users/lancedikson/Projects/videoly/shopify-apps/node/videoly-integration-app/node_modules/liquidjs/dist/liquid.node.cjs.js:2720:28)
    at repl:1:3
    at Script.runInThisContext (vm.js:123:20)
    at REPLServer.defaultEval (repl.js:384:29)
    at bound (domain.js:415:14) {
  originalError: AssertionError: "form_classes" not valid identifier
      at assert (/Users/lancedikson/Projects/videoly/shopify-apps/node/videoly-integration-app/node_modules/liquidjs/dist/liquid.node.cjs.js:774:15)
      at Object.parse (/Users/lancedikson/Projects/videoly/shopify-apps/node/videoly-integration-app/node_modules/liquidjs/dist/liquid.node.cjs.js:1774:9)
      at new Tag (/Users/lancedikson/Projects/videoly/shopify-apps/node/videoly-integration-app/node_modules/liquidjs/dist/liquid.node.cjs.js:1549:23)
      at Parser.parseToken (/Users/lancedikson/Projects/videoly/shopify-apps/node/videoly-integration-app/node_modules/liquidjs/dist/liquid.node.cjs.js:1639:24)
      at Parser.parse (/Users/lancedikson/Projects/videoly/shopify-apps/node/videoly-integration-app/node_modules/liquidjs/dist/liquid.node.cjs.js:1632:33)
      at Liquid.parse (/Users/lancedikson/Projects/videoly/shopify-apps/node/videoly-integration-app/node_modules/liquidjs/dist/liquid.node.cjs.js:2720:28)
      at repl:1:3
      at Script.runInThisContext (vm.js:123:20)
      at REPLServer.defaultEval (repl.js:384:29)
      at bound (domain.js:415:14) {
    name: 'AssertionError'

Haven't dived deeper yet, but it seems like Tokenizer is skipping quotes here.

@harttle harttle added the bug label Oct 3, 2020
@harttle harttle closed this as completed in 5b3f419 Oct 3, 2020
harttle pushed a commit that referenced this issue Oct 3, 2020
## [9.15.1](v9.15.0...v9.15.1) (2020-10-03)

### Bug Fixes

* allow quoted variable name in capture, fixes [#252](#252) ([5b3f419](5b3f419))
@harttle
Copy link
Owner

harttle commented Oct 3, 2020

🎉 This issue has been resolved in version 9.15.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

amit777 pushed a commit to amit777/liquidjs that referenced this issue Oct 7, 2020
amit777 pushed a commit to amit777/liquidjs that referenced this issue Oct 7, 2020
## [9.15.1](harttle/liquidjs@v9.15.0...v9.15.1) (2020-10-03)

### Bug Fixes

* allow quoted variable name in capture, fixes [harttle#252](harttle#252) ([5b3f419](harttle@5b3f419))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants