From fd8d0dc6e80f74f4dce7df7d07eb21334a2d4915 Mon Sep 17 00:00:00 2001 From: Ioan CHIRIAC Date: Sat, 20 Oct 2018 22:21:58 +0200 Subject: [PATCH] fix - use ExpressionStatement on static:: calls --- src/ast/this.js | 0 src/parser/statement.js | 8 +++--- .../snapshot/__snapshots__/class.test.js.snap | 27 ++++++++++--------- .../__snapshots__/variable.test.js.snap | 27 ++++++++++--------- 4 files changed, 34 insertions(+), 28 deletions(-) delete mode 100644 src/ast/this.js diff --git a/src/ast/this.js b/src/ast/this.js deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/parser/statement.js b/src/parser/statement.js index bf2611c2c..d30b5142b 100644 --- a/src/parser/statement.js +++ b/src/parser/statement.js @@ -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"); diff --git a/test/snapshot/__snapshots__/class.test.js.snap b/test/snapshot/__snapshots__/class.test.js.snap index 69ecd2b9d..1be3e61ae 100644 --- a/test/snapshot/__snapshots__/class.test.js.snap +++ b/test/snapshot/__snapshots__/class.test.js.snap @@ -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 [], diff --git a/test/snapshot/__snapshots__/variable.test.js.snap b/test/snapshot/__snapshots__/variable.test.js.snap index c58e60d2b..50d19c875 100644 --- a/test/snapshot/__snapshots__/variable.test.js.snap +++ b/test/snapshot/__snapshots__/variable.test.js.snap @@ -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 [],