natefaubion / sparkler

Native pattern matching for JavaScript
MIT License
693 stars 18 forks source link

guards do not allow function calls #10

Closed disnet closed 10 years ago

disnet commented 10 years ago
function foo {
    x @ Number if isPos(b) => 100
}

Throws:

Warning: Cannot read property 'constructor' of undefined Use --force to continue.
TypeError: Cannot read property 'constructor' of undefined
    at cloneSyntax$541 (eval at <anonymous> (/Users/tim/Dropbox/dev/sweet-virtual-values/node_modules/sweet.js/lib/scopedEval.js:16:69), <anonymous>:230:76)

Is this a sparkler or a sweet.js bug?

natefaubion commented 10 years ago

https://github.com/natefaubion/sparkler/blob/master/src/utils.js#L223-L232

It's a sparkler bug, but we need to expose syntax cloning as a method on syntax objects.

natefaubion commented 10 years ago

Fixed with https://github.com/natefaubion/sparkler/commit/5356009cf020add95cb9bcfd54bfc617357fe390