diff options
| author | 2021-04-23 13:42:27 -0700 | |
|---|---|---|
| committer | 2021-04-23 13:42:27 -0700 | |
| commit | b5174cf95f10c40da0d2a5d7715d450f4e7d4136 (patch) | |
| tree | 8da1acc1ad44dfb7bbed774c213c695506621cd0 /src | |
| parent | e78a991e282394c6f7dc32823a4e503327503499 (diff) | |
| download | bun-b5174cf95f10c40da0d2a5d7715d450f4e7d4136.tar.gz bun-b5174cf95f10c40da0d2a5d7715d450f4e7d4136.tar.zst bun-b5174cf95f10c40da0d2a5d7715d450f4e7d4136.zip | |
if
Diffstat (limited to 'src')
| -rw-r--r-- | src/js_parser.zig | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/js_parser.zig b/src/js_parser.zig index 8ac4eb238..1b9fa2785 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -1632,7 +1632,28 @@ const P = struct { return p.s(S.Local{ .kind = .k_const, .decls = decls, .is_export = opts.is_export }, loc); }, .t_if => { - notimpl(); + p.lexer.next(); + p.lexer.expect(.t_open_paren); + const test_ = p.parseExpr(.lowest); + p.lexer.expect(.t_close_paren); + var stmtOpts = ParseStatementOptions{ + .lexical_decl = .allow_fn_inside_if, + }; + const yes = p.parseStmt(&stmtOpts) catch unreachable; + var no: ?Stmt = null; + if (p.lexer.token == .t_else) { + p.lexer.next(); + stmtOpts = ParseStatementOptions{ + .lexical_decl = .allow_fn_inside_if, + }; + no = p.parseStmt(&stmtOpts) catch unreachable; + } + + return p.s(S.If{ + .test_ = test_, + .yes = yes, + .no = no, + }, loc); }, .t_do => { notimpl(); |
