MCPcopy Create free account
hub / github.com/babel/babel / parseReturnStatement

Function parseReturnStatement

packages/babel-parser/src/parser/statement.ts:973–992  ·  view source on GitHub ↗
(this: Parser, node: Undone<N.ReturnStatement>)

Source from the content-addressed store, hash-verified

971 }
972
973 parseReturnStatement(this: Parser, node: Undone<N.ReturnStatement>) {
974 if (!this.prodParam.hasReturn) {
975 this.raise(Errors.IllegalReturn, this.state.startLoc);
976 }
977
978 this.next();
979
980 // In `return` (and `break`/`continue`), the keywords with
981 // optional arguments, we eagerly look for a semicolon or the
982 // possibility to insert one.
983
984 if (this.isLineTerminator()) {
985 node.argument = null;
986 } else {
987 node.argument = this.parseExpression();
988 this.semicolon();
989 }
990
991 return this.finishNode(node, "ReturnStatement");
992 }
993
994 // https://tc39.es/ecma262/#prod-SwitchStatement
995 parseSwitchStatement(this: Parser, node: Undone<N.SwitchStatement>) {

Callers

nothing calls this directly

Calls 3

nextMethod · 0.80
finishNodeMethod · 0.80
semicolonMethod · 0.45

Tested by

no test coverage detected