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

Can't have #each argument called 'component' - results in name clash #251

Closed
antony opened this issue Jan 16, 2017 · 3 comments
Closed

Can't have #each argument called 'component' - results in name clash #251

antony opened this issue Jan 16, 2017 · 3 comments

Comments

@antony
Copy link
Member

antony commented Jan 16, 2017

I suppose this should be obvious really, but 'component' causes a name clash and an ugly stack trace:

    {{#each components as component}}
      <li>{{component}}</li>
    {{/each}}

Probably the internal 'component' parameter bound to renderEachBlock should be called something like __component or have a svelte unique identifier attached to it perhaps!

Stack trace Svelte compilation error { SyntaxError: Argument name clash (125:79) at Parser.pp$4.raise (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:2221:15) at Parser.pp$2.checkLVal (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:1475:16) at Parser.pp$3.checkParams (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:2136:16) at Parser.pp$3.parseFunctionBody (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:2119:12) at Parser.pp$1.parseFunction (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:1065:10) at Parser.pp$1.parseFunctionStatement (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:818:17) at Parser.pp$1.parseStatement (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:694:19) at Parser.pp$1.parseBlock (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:981:25) at Parser.pp$3.parseFunctionBody (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:2105:24) at Parser.pp$1.parseFunction (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:1065:10) at Parser.pp$3.parseExprAtom (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:1810:19) at Parser.parseExprAtom (/home/ant/Projects/vudash/packages/core/node_modules/buble/dist/buble.umd.js:656:26) at Parser.pp$3.parseExprSubscripts (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:1715:21) at Parser.pp$3.parseMaybeUnary (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:1692:19) at Parser.pp$3.parseExprOps (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:1637:21) at Parser.pp$3.parseMaybeConditional (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:1620:21) at Parser.pp$3.parseMaybeAssign (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:1597:21) at Parser.pp$3.parseParenAndDistinguishExpression (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:1861:32) at Parser.pp$3.parseExprAtom (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:1796:19) at Parser.parseExprAtom (/home/ant/Projects/vudash/packages/core/node_modules/buble/dist/buble.umd.js:656:26) at Parser.pp$3.parseExprSubscripts (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:1715:21) at Parser.pp$3.parseMaybeUnary (/home/ant/Projects/vudash/packages/core/node_modules/acorn/dist/acorn.js:1692:19) pos: 4372, loc: Position { line: 125, column: 79 }, raisedAt: 4900, snippet: '121 : }\n122 : };\n123 : }\n124 : \n125 : function renderEachBlock ( root, eachBlock_value, component, component__index, component ) {\n ^', toString: [Function] } undefined Debug: internal, implementation, error TypeError: Uncaught error: Cannot match against 'undefined' or 'null'. at ComponentRenderer.render (/home/ant/Projects/vudash/packages/core/src/modules/component-renderer/index.js:5:28) at Widget.toRenderModel (/home/ant/Projects/vudash/packages/core/src/modules/widget.js:52:29) at widgets.getWidgets.map (/home/ant/Projects/vudash/packages/core/src/modules/dashboard.js:84:23) at Array.map (native) at Dashboard.toRenderModel (/home/ant/Projects/vudash/packages/core/src/modules/dashboard.js:83:34) at handler (/home/ant/Projects/vudash/packages/core/src/plugins/dashboard.js:43:114) at Object.internals.handler (/home/ant/Projects/vudash/packages/core/node_modules/hapi/lib/handler.js:96:36) at request._protect.run (/home/ant/Projects/vudash/packages/core/node_modules/hapi/lib/handler.js:30:23) at internals.Protect.run (/home/ant/Projects/vudash/packages/core/node_modules/hapi/lib/protect.js:64:5) at exports.execute (/home/ant/Projects/vudash/packages/core/node_modules/hapi/lib/handler.js:24:22) at each (/home/ant/Projects/vudash/packages/core/node_modules/hapi/lib/request.js:383:16) at iterate (/home/ant/Projects/vudash/packages/core/node_modules/hapi/node_modules/items/lib/index.js:36:13) at done (/home/ant/Projects/vudash/packages/core/node_modules/hapi/node_modules/items/lib/index.js:28:25) at postValidate (/home/ant/Projects/vudash/packages/core/node_modules/hapi/lib/validation.js:68:20) at internals.Any._validateWithOptions (/home/ant/Projects/vudash/packages/core/node_modules/hapi/node_modules/joi/lib/any.js:664:16) at root.validate (/home/ant/Projects/vudash/packages/core/node_modules/hapi/node_modules/joi/lib/index.js:103:23) at Object.internals.input (/home/ant/Projects/vudash/packages/core/node_modules/hapi/lib/validation.js:137:20) at exports.params (/home/ant/Projects/vudash/packages/core/node_modules/hapi/lib/validation.js:48:22) at each (/home/ant/Projects/vudash/packages/core/node_modules/hapi/lib/request.js:383:16) at iterate (/home/ant/Projects/vudash/packages/core/node_modules/hapi/node_modules/items/lib/index.js:36:13) at done (/home/ant/Projects/vudash/packages/core/node_modules/hapi/node_modules/items/lib/index.js:28:25) at internals.Auth._authenticate (/home/ant/Projects/vudash/packages/core/node_modules/hapi/lib/auth.js:210:16)
@Rich-Harris
Copy link
Member

Yeah, this is another example of #222. Is very high on the priority list! Will close this issue in favour of that one — thanks

@antony
Copy link
Member Author

antony commented Jan 16, 2017

Whoops - didn't spot that one. Yep, that covers it exactly.

@Rich-Harris
Copy link
Member

This was (finally!) fixed just now, in 1.7.1

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

No branches or pull requests

2 participants