-
Notifications
You must be signed in to change notification settings - Fork 3
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 flag parsing into arg_from_ast #349
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Merged
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## inout/parse #349 +/- ##
===============================================
+ Coverage 92.64% 92.66% +0.02%
===============================================
Files 45 45
Lines 5164 5182 +18
===============================================
+ Hits 4784 4802 +18
Misses 380 380 ☔ View full report in Codecov by Sentry. |
This was referenced Aug 9, 2024
github-merge-queue bot
pushed a commit
that referenced
this pull request
Aug 22, 2024
This is the dev branch for the inout argument feature (tracked by #282). The idea is to allow explicit `@inout` annotations on function arguments that "give back" the passed value after the function returns: ```python @guppy def foo(q: qubit @inout) -> None: ... @guppy def bar(q1: qubit @inout, q2: qubit @inout) -> bool: ... @guppy def main() -> None: q1, q2 = qubit(), qubit() foo(q1) # Desugars to `q1 = foo(q1)` x = bar(q1, q2) # Desugars to `q1, q2, x = bar(q1, q2)` y = bar(q1, q1) # Error: Linearity violation, q1 used twice ``` To enable this, we need to enforce that `@inout` arguments are not moved in the body of the function (apart from passing them in another `@inout` position). This means that the argument will always be bound to the same name and never aliased which allows us to desugar `@inout` functions like ```python @guppy def bar(q1: qubit, q2: qubit) -> bool: [body] return [expr] ``` into ```python @guppy def bar(q1: qubit, q2: qubit) -> tuple[qubit, qubit, bool]: [body] return q1, q2, [expr] # Linearity checker needs to ensure that q1, q2 are unused ``` Note that we only allow `@inout` annotations on linear types, since they would be useless for classical ones (unless we also implement an ownership system for classical values). Supporting them would make the checking logic more complicated without providing any meaningful benefit. Tracked PRs: * #315 * #316 * #349 * #344 * #321 * #331 * #350 * #339 * #340 * #351
github-merge-queue bot
pushed a commit
that referenced
this pull request
Sep 11, 2024
🤖 I have created a release *beep* *boop* --- ## [0.10.0](v0.9.0...v0.10.0) (2024-09-11) ### ⚠ BREAKING CHANGES * Bumped the `hugr` dependency to `0.8.0` * `GuppyModule.load` no longer loads the content of modules but instead just brings the name of the module into scope. Use `GuppyModule.load_all` to get the old behaviour. * Removed `guppylang.hugr_builder.hugr.Hugr`, compiling a module returns a `hugr.Package` instead. ### Features * Add `__version__` field to guppylang ([#473](#473)) ([b996c62](b996c62)) * Add angle type ([#449](#449)) ([12e41e0](12e41e0)) * Add array literals ([#446](#446)) ([a255c02](a255c02)) * Add equality test for booleans ([#394](#394)) ([dd702ce](dd702ce)), closes [#363](#363) * Add pi constant ([#451](#451)) ([9d35a78](9d35a78)) * Add qualified imports and make them the default ([#443](#443)) ([553ec51](553ec51)) * Allow calling of methods ([#440](#440)) ([5a59da3](5a59da3)) * Allow imports of function definitions and aliased imports ([#432](#432)) ([e23b666](e23b666)) * Array indexing ([#415](#415)) ([2199b48](2199b48)), closes [#421](#421) [#422](#422) [#447](#447) * Inout arguments ([#311](#311)) ([060649b](060649b)), closes [#315](#315) [#316](#316) [#349](#349) [#344](#344) [#321](#321) [#331](#331) [#350](#350) [#340](#340) [#351](#351) * range() with single-argument ([#452](#452)) ([d05f369](d05f369)) * Skip checking of redefined functions ([#457](#457)) ([7f9ad32](7f9ad32)) * Support `nat`/`int` ↔ `bool` cast operations ([#459](#459)) ([3b778c3](3b778c3)) * Use `hugr-cli` for validation ([#455](#455)) ([1d0667b](1d0667b)) * Use cell name instead of file for notebook errors ([#382](#382)) ([d542601](d542601)) * Use the hugr builder ([536abf9](536abf9)) ### Bug Fixes * Fix and update demo notebook ([#376](#376)) ([23b2a15](23b2a15)) * Fix linearity checking bug ([#441](#441)) ([0b8ea21](0b8ea21)) * Fix struct definitions in notebooks ([#374](#374)) ([b009465](b009465)) ### Documentation * Update readme, `cargo build` instead of `--extra validation` ([#471](#471)) ([c2a4c86](c2a4c86)) ### Miscellaneous Chores * Update hugr to `0.8.0` ([#454](#454)) ([b02e0d0](b02e0d0)) --- 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
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.
Closes #347 and closes #312