satyr / coco

Unfancy CoffeeScript
http://satyr.github.com/coco/
MIT License
498 stars 48 forks source link

unable to use `const` and `export` keywords together #150

Closed andrewrk closed 12 years ago

andrewrk commented 12 years ago

I expect to be able to write:

export const PI = 3.14

However this yields:

Error: Parse error on line 1: Unexpected 'DECL'

I noticed that I can do:

export (const PI = 3.14)

However this results in the javascript code:

var PI, __out = typeof exports != 'undefined' && exports || this;
__import(__out, PI = 3.14);
function __import(obj, src){
  var own = {}.hasOwnProperty;
  for (var key in src) if (own.call(src, key)) obj[key] = src[key];
  return obj;
}

We shouldn't depend on the __import runtime function to export a constant.

satyr commented 12 years ago

Right now you can't nest declarations. I guess we can allow export const though.