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

feat: Allow constant nats as type args #255

Merged
merged 27 commits into from
Jun 25, 2024
Merged

feat: Allow constant nats as type args #255

merged 27 commits into from
Jun 25, 2024

Conversation

mark-koch
Copy link
Collaborator

I recommend reviewing commit by commit

Closes #214

@mark-koch mark-koch requested a review from ss2165 June 19, 2024 15:57
Comment on lines +3 to +6
7: @guppy(module)
8: def main(x: array[int, bool]) -> None:
^^^^^^^^^^^^^^^^
GuppyTypeError: Expected argument of type `nat`, got type
Copy link
Collaborator Author

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

Copy link
Member

@ss2165 ss2165 left a 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 Show resolved Hide resolved
"""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)
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

fun

@mark-koch mark-koch force-pushed the feat/nats branch 2 times, most recently from 0d37aef to b664d2c Compare June 24, 2024 16:31
Base automatically changed from feat/nats to main June 24, 2024 16:46
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 74.85380% with 43 lines in your changes missing coverage. Please review.

Project coverage is 90.67%. Comparing base (a461a9d) to head (b03962f).

Files Patch % Lines
guppylang/tys/arg.py 21.05% 15 Missing ⚠️
guppylang/tys/param.py 57.14% 9 Missing ⚠️
guppylang/tys/const.py 77.41% 7 Missing ⚠️
guppylang/tys/ty.py 85.00% 6 Missing ⚠️
guppylang/tys/builtin.py 44.44% 5 Missing ⚠️
guppylang/tys/subst.py 94.11% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@mark-koch mark-koch merged commit d706735 into main Jun 25, 2024
3 checks passed
@mark-koch mark-koch deleted the feat/nat-args branch June 25, 2024 08:08
github-merge-queue bot pushed a commit that referenced this pull request Jul 2, 2024
🤖 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).
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.

Add nat type parameters
3 participants