diff options
| author | Mel <einebeere@gmail.com> | 2022-03-03 02:30:46 +0100 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2022-03-03 02:30:46 +0100 |
| commit | f5bb7bbd8824a20c991587d5a774644aa98241d9 (patch) | |
| tree | c8729e0e1a04f2c924b5351f57fb9b2ec18d4633 /src/interpret/walker.rs | |
| parent | 8f7e3d1d2cd43d30ccc16799fcf69058ccc5a717 (diff) | |
| download | rabbithole-main.tar.zst rabbithole-main.zip | |
Diffstat (limited to 'src/interpret/walker.rs')
| -rw-r--r-- | src/interpret/walker.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/interpret/walker.rs b/src/interpret/walker.rs index 7c86780..07e127d 100644 --- a/src/interpret/walker.rs +++ b/src/interpret/walker.rs @@ -62,12 +62,16 @@ impl Walker { println!("{}", result); None } - // FIXME: Returns are always expected to have a return even though `return;` is valid. StatementKind::Return(node) => { + let returned = match node { + Some(e) => Some(self.walk_expression(e)?), + None => None, + }; + // If there's a function running above us it will catch this error. return Err(WalkerError::new( statement.at, - WalkerErrorKind::Return(self.walk_expression(node)?), + WalkerErrorKind::Return(returned), )); } StatementKind::Break(node) => { @@ -381,5 +385,5 @@ pub enum WalkerErrorKind { LoopBreak(Option<Value>), // Same as with the loop control errors, but for functions. #[error("Return statements are only valid inside functions.")] - Return(Value), + Return(Option<Value>), } |
