-
Notifications
You must be signed in to change notification settings - Fork 2
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: Allow constant nats as type args #255
Conversation
Co-authored-by: Craig Roy <croyzor@users.noreply.github.com>
7: @guppy(module) | ||
8: def main(x: array[int, bool]) -> None: | ||
^^^^^^^^^^^^^^^^ | ||
GuppyTypeError: Expected argument of type `nat`, got type |
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.
The unspecific error location is expected, a bigger refactor is required to track the source locations of type args
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.
fantastic
guppylang/tys/ty.py
Outdated
"""Helper function for unification of type variables.""" | ||
def _unify_var(var: ExistentialVar, t: Type | Const, subst: "Subst") -> "Subst | None": | ||
"""Helper function for unification of type or const variables.""" | ||
assert isinstance(var, ExistentialTypeVar | ExistentialConstVar) |
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.
seems odd for this to not be the type annotation, some subtype vs union shenanigans?
@@ -94,6 +94,9 @@ def arg_from_ast( | |||
# right now. | |||
# TODO: Once we also have int args etc, we need proper inference logic here | |||
if isinstance(node, ast.Constant) and isinstance(node.value, int): | |||
# Fun fact: int ast.Constant values are never negative since e.g. `-5` is a |
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.
fun
0d37aef
to
b664d2c
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #255 +/- ##
==========================================
- Coverage 90.90% 90.67% -0.24%
==========================================
Files 44 44
Lines 4839 4954 +115
==========================================
+ Hits 4399 4492 +93
- Misses 440 462 +22 ☔ View full report in Codecov by Sentry. |
🤖 I have created a release *beep* *boop* --- ## [0.6.0](v0.5.2...v0.6.0) (2024-07-02) ### Features * Add array type ([#258](#258)) ([041c621](041c621)) * Add nat type ([#254](#254)) ([a461a9d](a461a9d)) * Add result function ([#271](#271)) ([792fb87](792fb87)), closes [#270](#270) * Allow constant nats as type args ([#255](#255)) ([d706735](d706735)) * Generate constructor methods for structs ([#262](#262)) ([f68d0af](f68d0af)), closes [#261](#261) * Return already-compiled hugrs from `GuppyModule.compile` ([#247](#247)) ([9d01eae](9d01eae)) * Turn int and float into core types ([#225](#225)) ([99217dc](99217dc)) ### Bug Fixes * Add missing test file ([#266](#266)) ([75231fe](75231fe)) * Loading custom polymorphic function defs as values ([#260](#260)) ([d15b2f5](d15b2f5)), closes [#259](#259) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
I recommend reviewing commit by commit
Closes #214