()
| 2399 | // https://tc39.github.io/ecma262/#sec-return-statement |
| 2400 | |
| 2401 | parseReturnStatement(): Node.ReturnStatement { |
| 2402 | if (!this.context.inFunctionBody) { |
| 2403 | this.tolerateError(Messages.IllegalReturn); |
| 2404 | } |
| 2405 | |
| 2406 | const node = this.createNode(); |
| 2407 | this.expectKeyword('return'); |
| 2408 | |
| 2409 | const hasArgument = (!this.match(';') && !this.match('}') && |
| 2410 | !this.hasLineTerminator && this.lookahead.type !== Token.EOF) || |
| 2411 | this.lookahead.type === Token.StringLiteral || |
| 2412 | this.lookahead.type === Token.Template; |
| 2413 | |
| 2414 | const argument = hasArgument ? this.parseExpression() : null; |
| 2415 | this.consumeSemicolon(); |
| 2416 | |
| 2417 | return this.finalize(node, new Node.ReturnStatement(argument)); |
| 2418 | } |
| 2419 | |
| 2420 | // https://tc39.github.io/ecma262/#sec-with-statement |
| 2421 |
no test coverage detected