Skip to content

Commit

Permalink
fix - use ExpressionStatement on static:: calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ichiriac committed Oct 20, 2018
1 parent 1030beb commit fd8d0dc
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 28 deletions.
Empty file removed src/ast/this.js
Empty file.
8 changes: 4 additions & 4 deletions src/parser/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,20 +253,20 @@ module.exports = {

case this.tok.T_STATIC:
current = [this.token, this.lexer.getState()];
result = this.node("static");
result = this.node();
if (this.next().token === this.tok.T_DOUBLE_COLON) {
// static keyword for a class
this.lexer.tokens.push(current);
expr = this.next().read_expr();
this.expect(";") && this.next();
return expr;
this.expectEndOfStatement(expr);
return result("expressionstatement", expr);
}
if (this.token === this.tok.T_FUNCTION) {
return this.read_function(true, [0, 1, 0]);
}
items = this.read_variable_declarations();
this.expectEndOfStatement();
return result(items);
return result("static", items);

case this.tok.T_ECHO: {
result = this.node("echo");
Expand Down
27 changes: 15 additions & 12 deletions test/snapshot/__snapshots__/class.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -305,20 +305,23 @@ Program {
},
},
},
Call {
"arguments": Array [],
"kind": "call",
"what": StaticLookup {
"kind": "staticlookup",
"offset": Identifier {
"kind": "identifier",
"name": "baz",
},
"what": Identifier {
"kind": "identifier",
"name": "static",
ExpressionStatement {
"expression": Call {
"arguments": Array [],
"kind": "call",
"what": StaticLookup {
"kind": "staticlookup",
"offset": Identifier {
"kind": "identifier",
"name": "baz",
},
"what": Identifier {
"kind": "identifier",
"name": "static",
},
},
},
"kind": "expressionstatement",
},
Call {
"arguments": Array [],
Expand Down
27 changes: 15 additions & 12 deletions test/snapshot/__snapshots__/variable.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -275,20 +275,23 @@ Program {
exports[`Test variables Class constants 1`] = `
Program {
"children": Array [
Call {
"arguments": Array [],
"kind": "call",
"what": StaticLookup {
"kind": "staticlookup",
"offset": Identifier {
"kind": "identifier",
"name": "foo",
},
"what": Identifier {
"kind": "identifier",
"name": "static",
ExpressionStatement {
"expression": Call {
"arguments": Array [],
"kind": "call",
"what": StaticLookup {
"kind": "staticlookup",
"offset": Identifier {
"kind": "identifier",
"name": "foo",
},
"what": Identifier {
"kind": "identifier",
"name": "static",
},
},
},
"kind": "expressionstatement",
},
Call {
"arguments": Array [],
Expand Down

0 comments on commit fd8d0dc

Please sign in to comment.