-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improper void value expression #2821
Comments
Could you report this to https://bugs.ruby-lang.org/ to see if CRuby considers it a bug? Also, is it literally |
Re Playing with it on CRuby I guess the error means Then maybe the question is if one branch is void and the other not should it be an error or not. |
def m
x = begin
if rand < 0.5
return :hi
else
return nil
end
end
end
puts m is an error on CRuby. So I guess if all branch are void it complains. |
The method for this is |
#2823 and I think no need to ask CRuby about this, the CRuby behavior seems sensible, i.e., only error if none of the branch returns a value (i.e., is non-void, i.e., does not exit via break/return/etc) |
We have a parsing difference from MRI that results in an improper
SyntaxError
. It's related to returning from abegin
block used in an assignment.This could possibly be an MRI bug and is almost certainly an application logic error. If the
return
expression isn't nested in a conditional like it is here, then MRI does raise theSyntaxError
. E.g.:The text was updated successfully, but these errors were encountered: