Skip to content
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

Add warning for return x in spawn context #228

Merged
merged 1 commit into from
Nov 24, 2020

Conversation

pali6
Copy link
Contributor

@pali6 pali6 commented Nov 5, 2020

As far as I know doing return something in a spawn context is always equivalent to just returning without a value and as such it is probably a mistake so let's warn people about it.

@@ -1281,6 +1281,11 @@ impl<'o, 's> AnalyzeProc<'o, 's> {
},
Statement::Return(Some(expr)) => {
// TODO: factor in the previous return type if there was one
if self.inside_newcontext > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC isn't this also set in waitfor = 0 procs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, the only place that changes inside_newcontext to non-zero values seems to be the Statement::Spawn match arm.

@spookydonut spookydonut changed the title Adds warning for return x in spawn context Add warning for return x in spawn context Nov 24, 2020
@spookydonut spookydonut merged commit 650daa0 into SpaceManiac:master Nov 24, 2020
@SpaceManiac SpaceManiac added this to the suite v1.7 milestone Dec 9, 2020
j-awn pushed a commit to j-awn/SpacemanDMM that referenced this pull request Apr 1, 2021
@pali6 pali6 deleted the warn-return-value-in-spawn branch February 7, 2022 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants