Skip to content

Commit 981e08d

Browse files
committed
glayzzle#41 make functions & closures more consistent
1 parent c79d63a commit 981e08d

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/parser/function.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ module.exports = {
7979
if (this.token === ':') {
8080
returnType = this.next().read_type();
8181
}
82-
return result(name, params, isRef, use, returnType);
82+
if (type === 1) {
83+
return result(params, isRef, use, returnType);
84+
}
85+
return result(name, params, isRef, returnType);
8386
}
8487
/**
8588
* <ebnf>

test/functional/commentTests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('Test comments', function() {
5959
ast[1][1][0].should.be.exactly("function");
6060
ast[1][1][1].should.be.exactly("name");
6161
ast[1][1][2].length.should.be.exactly(1);
62-
var body = ast[1][1][6];
62+
var body = ast[1][1][5];
6363
body[0][0].should.be.exactly('comment');
6464
body[1][0].should.be.exactly('return');
6565
});

test/functional/gracefulTests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('Test graceful mode', function() {
2222
'}' // 5. <-- extra '}' token here
2323
].join('\n'));
2424
ast[2].length.should.be.exactly(2);
25-
ast[1][0][2][6][0][2][0].should.be.exactly('error');
25+
ast[1][0][2][5][0][2][0].should.be.exactly('error');
2626
});
2727

2828
it('test expr', function () {

0 commit comments

Comments
 (0)