anko / eslisp

un-opinionated S-expression syntax and macro system for JavaScript
ISC License
528 stars 31 forks source link

Try-catch with anything other than an s-expression throws a TypeError #30

Closed dead-claudia closed 8 years ago

dead-claudia commented 8 years ago

That stack trace should be descriptive enough. I tried every possible atom that wasn't an s-expression, and it always throws.

$ eslc <<<'(try foo (catch (e)))'

${NPM_DIR}/eslisp/lib/cli.js:73
      throw err;
      ^

TypeError: Cannot read property '0' of undefined
    at isPart (${NPM_DIR}/eslisp/lib/built-in-macros.js:506:28)
    at ${NPM_DIR}/eslisp/lib/built-in-macros.js:513:11
    at Array.forEach (native)
    at contents.try (${NPM_DIR}/eslisp/lib/built-in-macros.js:512:10)
    at list.prototype.compile (${NPM_DIR}/eslisp/lib/ast.js:188:14)
    at ${NPM_DIR}/eslisp/lib/translate.js:34:17
    at ${NPM_DIR}/eslisp/node_modules/prelude-ls/lib/List.js:158:21
    at ${NPM_DIR}/eslisp/node_modules/prelude-ls/lib/List.js:161:4
    at ${NPM_DIR}/eslisp/node_modules/prelude-ls/lib/List.js:665:42
    at module.exports (${NPM_DIR}/eslisp/lib/translate.js:35:7)

I expected it to print out something like this:

try {
  foo;
} catch (e) {
  bar;
}
anko commented 8 years ago

Thanks for the catch! Fixed in v0.6.2.