Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feat: Move type checking code and make it bidirectional #58
feat: Move type checking code and make it bidirectional #58
Changes from 16 commits
871b14c
b0f482e
0f1c428
0851fd6
0b4ee03
708ab55
6ea1df5
867e982
d09ce09
05dc741
b2ad478
61e2cba
302e2aa
145c6aa
6b833cb
29c6009
f982901
55d7271
6e3c2f3
dacc31f
a872eed
43e25e3
4de95e8
34db487
c522771
f930ecc
f5e60cf
2f29f2f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to catch a
KeyError
exception here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case should never occur since Guppy doesn't let users write functions that don't return:
This is because Guppy program analysis doesn't take the semantics of
True
andFalse
into account. As a result, the exit BB in a CFG will always be reachable in the graph.In the future, we might allow users to write infinitely looping functions that don't require the
return
statement at the end. Then we would need to be more careful about this lineThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failures on
assert
s should probably raise internal errors.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I typically use asserts as a concise check and documentation of invariants. We could catch
AssertionErrors
on the top-level and turn them intoInternalGuppyErrors
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably fine. ruff tells me it's usually a good idea to avoid them in production code as they might get erased with certain compilation flags. Unsure how much of a concern are they in your case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this mean something different? Confused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this line is a regular string, not an fstring, so it is the actual char sequence
"{0}"
.When referring to code locations in error messages, we put the format placeholders
{0}
,{1}
, etc and store the corresponding AST nodes in the error, instead of baking the location into the string. The reasoning is that this gives us more flexibility in how we want to display source locations when printing the errorThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I must have misread that as part of an f-string. Thanks for the explanation.