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

parser: Harden return statements #23

Merged
merged 4 commits into from
Oct 5, 2022
Merged

parser: Harden return statements #23

merged 4 commits into from
Oct 5, 2022

Conversation

juliaogris
Copy link
Member

Harden return statements such that there is an error when there is
unreachable code after a return statement or a return statement is of
the wrong type.

@github-actions
Copy link

github-actions bot commented Oct 5, 2022

Visit the preview URL for this PR (updated for commit 0b2202d):

https://evy-lang--pr23-return-errors-qvps6m8p.web.app

(expires Wed, 12 Oct 2022 08:16:10 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Unify statement parsing for program and block - just a small refactor in
order to not repeat myself.
@juliaogris juliaogris force-pushed the return-errors branch 4 times, most recently from ceff6b7 to 50c8cc5 Compare October 5, 2022 04:26
Copy link
Contributor

@camh- camh- left a comment

Choose a reason for hiding this comment

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

some stuff to get you going, but i really like how this looks. again, reasonably simple to add means its in pretty good shape

pkg/parser/ast.go Outdated Show resolved Hide resolved
pkg/parser/ast.go Outdated Show resolved Hide resolved
pkg/parser/parser.go Outdated Show resolved Hide resolved
pkg/parser/parser.go Outdated Show resolved Hide resolved
pkg/parser/parser.go Outdated Show resolved Hide resolved
pkg/parser/parser.go Outdated Show resolved Hide resolved
pkg/parser/parser_test.go Outdated Show resolved Hide resolved
@juliaogris juliaogris force-pushed the return-errors branch 2 times, most recently from 069ee1f to 57c421e Compare October 5, 2022 07:53
Copy link
Contributor

@camh- camh- left a comment

Choose a reason for hiding this comment

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

🐲 bloody beautiful

Ensure correct return type according to function signature, append error
otherwise.
Add error message for unreachable code after `return` statement.
Ensure functions with specified return type always return, print error
otherwise.
@juliaogris juliaogris merged commit 037d375 into master Oct 5, 2022
@juliaogris juliaogris deleted the return-errors branch October 5, 2022 09:43
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.

None yet

2 participants