satyr/coco

inconsistent export behavior

andrewrk opened this issue · 1 comments

http://satyr.github.com/cup/#c:export%20const%20foo1%20=%20-%3E%20%22hi%22%0A%0Aconst%20foo2%20=%20-%3E%20%22hi%22%0Aexport%20foo2

code:

export const foo1 = -> "hi"

const foo2 = -> "hi"
export foo2

expected:

var foo1, foo2, out$ = typeof exports != 'undefined' && exports || this;
foo1 = function(){
  return "hi";
};
out$.foo1 = foo1;
foo2 = function(){
  return "hi";
};
out$.foo2 = foo2;

actual:

var foo1, foo2, out$ = typeof exports != 'undefined' && exports || this;
import$(out$, foo1 = function(){
  return "hi";
});
foo2 = function(){
  return "hi";
};
out$.foo2 = foo2;
function import$(obj, src){
  var own = {}.hasOwnProperty;
  for (var key in src) if (own.call(src, key)) obj[key] = src[key];
  return obj;
}

Looks like I forgot to make it unroll sub-blocks and managed to write a wrong test. Fixing.