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

javascript reduce doesn't work with arrow function #109

Open
steebchen opened this issue Sep 11, 2016 · 5 comments
Open

javascript reduce doesn't work with arrow function #109

steebchen opened this issue Sep 11, 2016 · 5 comments
Labels

Comments

@steebchen
Copy link

steebchen commented Sep 11, 2016

This line

@[0, 1, 2].reduce((a, b) => a + b)

throws this

ReferenceError: Problem while rendering template at line 19, character 0.
Original message: Problem while rendering template at line 19, character 0.
Original message: a is not defined.
Context: 

   18 |  <div class="value">
 > 19 |      @[0, 1, 2].reduce((a, b) => a)
   20 |  </div>

.
Context: 

   at eval (eval at <anonymous> ([cut]/node_modules/vash/runtime.js:308:26), <anonymous>:342:72)
   at linked ([cut]/node_modules/vash/runtime.js:348:14)
   at [cut]/node_modules/vash/lib/helpers/layout.js:232:5
   at Object.vash.loadFile ([cut]/node_modules/vash/lib/helpers/layout.js:68:11)
   at Helpers.helpers.include ([cut]/node_modules/vash/lib/helpers/layout.js:230:8)
   at eval (eval at <anonymous> ([cut]/node_modules/vash/runtime.js:308:26), <anonymous>:91:33)
   at Helpers.helpers.block ([cut]/node_modules/vash/lib/helpers/layout.js:253:5)
   at eval (eval at <anonymous> ([cut]/node_modules/vash/runtime.js:308:26), <anonymous>:61:33)
   at [cut]/node_modules/vash/lib/helpers/layout.js:197:5
   at Object.vash.loadFile ([cut]/node_modules/vash/lib/helpers/layout.js:68:11)
   at Helpers.helpers.extend ([cut]/node_modules/vash/lib/helpers/layout.js:188:8)
   at eval (eval at <anonymous> ([cut]/node_modules/vash/runtime.js:308:26), <anonymous>:10:33)
   at linked ([cut]/node_modules/vash/runtime.js:348:14)
   at [cut]/node_modules/vash/lib/helpers/layout.js:80:22
   at Object.vash.loadFile ([cut]/node_modules/vash/lib/helpers/layout.js:68:11)
   at View.vash.renderFile.vash.__express [as engine] ([cut]/node_modules/vash/lib/helpers/layout.js:76:8)
   at View.render ([cut]/node_modules/express/lib/view.js:126:8)
   at tryRender ([cut]/node_modules/express/lib/application.js:639:10)
   at EventEmitter.render ([cut]/node_modules/express/lib/application.js:591:3)
   at ServerResponse.render ([cut]/node_modules/express/lib/response.js:960:7)
   at [cut]/app.js:98:6
   at Layer.handle [as handle_request] ([cut]/node_modules/express/lib/router/layer.js:95:5)
   at next ([cut]/node_modules/express/lib/router/route.js:131:13)
   at [cut]/app.js:93:3
   at [cut]/node_modules/mongoose/lib/query.js:2257:18
   at process._tickDomainCallback (node.js:438:9)

while this

@[0, 1, 2].reduce(function(a, b) { return a + b })

works.

node@v5.9.1
vash@0.12.1

@yannik-b
Copy link

This is special syntax of ECMAScript 6. Like several web browsers, vash doesn't support ES6 yet.

@steebchen
Copy link
Author

I am aware of that and I am asking this because @[0, 1, 2].map(i => i + 1) works perfectly.

@kirbysayshi
Copy link
Owner

I believe the problem is that vash is "optimizing" out the nested parens because it doesn't know about arrow functions.

I don't plan to add official ES2015 support to vash at this time.

@kirbysayshi kirbysayshi added the bug label May 8, 2017
@steebchen
Copy link
Author

Yep, that's okay, I was just wondering.

@ovitrif
Copy link

ovitrif commented Apr 11, 2022

I don't plan to add official ES2015 support to vash at this time.

@kirbysayshi would you mind contributions for it though?

I feel it's very bad when sometimes arrow functions work, sometimes not... that's the recipe for wasting hundreds of hours not knowing what to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants