Skip to content

Commit e437a71

Browse files
committed
glayzzle#70 fix errors arguments list
1 parent d11d708 commit e437a71

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

RELEASE.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Releases
22

3+
## 2.1.0 : pending
4+
5+
- Fix AST errors on suppressErrors
6+
37
## 2.0.0 : (2017-03-04)
48

59
- Update AST for operators, unify bin/bool/coalesce nodes

src/parser/function.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,13 @@ module.exports = {
184184
if (this.token !== ')') {
185185
while(this.token != this.EOF) {
186186
var argument = this.read_argument_list();
187-
result.push(argument);
188-
if (argument.kind === 'variadic') {
189-
wasVariadic = true;
190-
} else if (wasVariadic) {
191-
this.raiseError('Unexpected argument after a variadic argument');
187+
if (argument) {
188+
result.push(argument);
189+
if (argument.kind === 'variadic') {
190+
wasVariadic = true;
191+
} else if (wasVariadic) {
192+
this.raiseError('Unexpected argument after a variadic argument');
193+
}
192194
}
193195
if (this.token === ',') {
194196
this.next();

test/gracefulTests.js

+19
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,25 @@ describe('Test graceful mode', function() {
7070
ast.children[0].kind.should.be.exactly('interface');
7171
});
7272

73+
it('test function arguments', function () {
74+
// test.parser.debug = true;
75+
var ast = test.parseEval([
76+
'$foo->bar($arg, );',
77+
'$foo = new bar($baz, ,$foo);'
78+
].join('\n'));
79+
var callNode = ast.children[0];
80+
callNode.kind.should.be.exactly('call');
81+
callNode.what.kind.should.be.exactly('propertylookup');
82+
callNode.arguments.length.should.be.exactly(1);
83+
callNode.arguments[0].name.should.be.exactly('arg');
84+
var assignNode = ast.children[1];
85+
assignNode.kind.should.be.exactly('assign');
86+
assignNode.right.kind.should.be.exactly('new');
87+
assignNode.right.arguments[0].name.should.be.exactly('baz');
88+
// the supressError mode cant guarantee $foo to be included into the arguments list
89+
});
90+
91+
7392
});
7493

7594
});

0 commit comments

Comments
 (0)