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

Control can reach the end of non-void functions #5

Closed
elliottt opened this issue Jun 25, 2013 · 1 comment
Closed

Control can reach the end of non-void functions #5

elliottt opened this issue Jun 25, 2013 · 1 comment

Comments

@elliottt
Copy link
Contributor

elliottt commented Jun 25, 2013

There's not currently a way to enforce that code paths terminate in a use of ret or retVoid in a proc. It's not clear if there's a way to do this, but a good example of the problem is this:

test = proc "test" $ body $ (ifte_ false (ret true) (return ()))

This will typecheck and generate code, though the generated C will include a path that would return no value, and generate a warning.

@leepike
Copy link
Contributor

leepike commented Oct 24, 2016

The type-checking pass over the AST now catches this. The following warnings and errors are produced from compiling the above function:

*** procedure/area test WARNING: One branch of an if-then-else statement contains a return statement. Statements after the if-the-else block are not reachable on all control paths.
*** procedure/area test ERROR: No return statement and procedure has a non-void type.
*** Exception: There were type-checking errors.

@leepike leepike closed this as completed Oct 24, 2016
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

No branches or pull requests

2 participants