Skip to content

Commit

Permalink
fixed #165, export const
Browse files Browse the repository at this point in the history
  • Loading branch information
satyr committed Sep 5, 2012
1 parent 3737564 commit bb5b5a3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -3223,6 +3223,10 @@ DECLS = {
i = -1;
out = Util('out');
while (node = lines[++i]) {
if (node instanceof Block) {
lines.splice.apply(lines, [i--, 1].concat(slice$.call(node.lines)));
continue;
}
if (that = node instanceof Fun && node.name) {
lines.splice(i++, 0, Assign(Chain(out, [Index(Key(that))]), Var(that)));
continue;
Expand Down
3 changes: 3 additions & 0 deletions src/ast.co
Original file line number Diff line number Diff line change
Expand Up @@ -1978,6 +1978,9 @@ DECLS =
export: (lines) ->
i = -1; out = Util \out
while node = lines[++i]
if node instanceof Block
lines.splice i-- 1 ...node.lines
continue
if node instanceof Fun and node.name
lines.splice i++ 0 Assign Chain(out, [Index Key that]), Var that
continue
Expand Down
9 changes: 7 additions & 2 deletions test/declaration.co
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ let
d = 4
[e, f] = [5, 6]
export const g = 7
eq '1,2,3,4,5,6,7' [a, b, c, d, e, f, g]join!
ok out.g, g
export
const h = 8
const i = 9
eq '1,2,3,4,5,6,7,8,9' ''+[a, b, c, d, e, f, g, h, i]
eq out.g, g
eq out.h, h
eq out.i, i

compileThrows 'redeclaration of constant "a"' 2 '''
const a = 0
Expand Down

0 comments on commit bb5b5a3

Please sign in to comment.