Skip to content

Commit 3b39831

Browse files
committed
fix: catch without variable version check
1 parent 840958e commit 3b39831

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/parser/try.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = {
2929
this.next().expect("(") && this.next();
3030
const what = this.read_list(this.read_namespace_name, "|", false);
3131
let variable = null;
32-
if (this.token === this.tok.T_VARIABLE) {
32+
if (this.version < 800 || this.token === this.tok.T_VARIABLE) {
3333
variable = this.read_variable(true, false);
3434
}
3535
this.expect(")");

test/snapshot/try.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ describe("boolean", () => {
1313
parser.parseEval("try { call(); } catch (Exception) { do_something(); }")
1414
).toMatchSnapshot();
1515
});
16+
it("without variable in PHP < 8", () => {
17+
expect(() =>
18+
parser.parseEval(
19+
"try { call(); } catch (Exception) { do_something(); }",
20+
{ parser: { version: "7.4" } }
21+
)
22+
).toThrow(SyntaxError);
23+
});
1624
it("qualified name", () => {
1725
expect(
1826
parser.parseEval(

0 commit comments

Comments
 (0)