MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / return_statement

Method return_statement

aiscript-vm/src/parser/mod.rs:1200–1215  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

1198 }
1199
1200 fn return_statement(&mut self) -> Option<Stmt<'gc>> {
1201 let value = if !self.check(TokenType::Semicolon) {
1202 if self.fn_type == FunctionType::Constructor {
1203 self.error("Can't return a value from an constructor.");
1204 }
1205 Some(self.expression()?)
1206 } else {
1207 None
1208 };
1209
1210 self.consume(TokenType::Semicolon, "Expect ';' after return value.");
1211 Some(Stmt::Return {
1212 value,
1213 line: self.previous.line,
1214 })
1215 }
1216
1217 fn expression_statement(&mut self) -> Option<Stmt<'gc>> {
1218 let expr = self.expression()?;

Callers 1

statementMethod · 0.80

Calls 4

checkMethod · 0.80
expressionMethod · 0.80
errorMethod · 0.45
consumeMethod · 0.45

Tested by

no test coverage detected