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: Add TailLoop::BREAK_TAG and CONTINUE_TAG #1626

Merged
merged 2 commits into from
Nov 5, 2024
Merged

Conversation

acl-cqc
Copy link
Contributor

@acl-cqc acl-cqc commented Nov 4, 2024

It doesn't seem obvious to me which way round these should be, so add constants, and use for the "definitive" make_break and make_continue.

No change to python as this doesn't even have make_break or make_continue ATM.

Copy link

codecov bot commented Nov 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.78%. Comparing base (9962f97) to head (10e821e).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1626   +/-   ##
=======================================
  Coverage   85.78%   85.78%           
=======================================
  Files         136      136           
  Lines       25135    25143    +8     
  Branches    22061    22069    +8     
=======================================
+ Hits        21561    21569    +8     
  Misses       2425     2425           
  Partials     1149     1149           
Flag Coverage Δ
python 92.45% <ø> (ø)
rust 84.85% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@acl-cqc acl-cqc marked this pull request as ready for review November 4, 2024 14:13
@acl-cqc acl-cqc requested a review from a team as a code owner November 4, 2024 14:13
Copy link
Contributor

@mark-koch mark-koch left a comment

Choose a reason for hiding this comment

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

Looks good to me, AFAIK the Python builder doesn't even have make_continue and make_break.

Should we use these CONTINUE_TAG and BREAK_TAG constants also during validation?

@acl-cqc
Copy link
Contributor Author

acl-cqc commented Nov 4, 2024

Should we use these CONTINUE_TAG and BREAK_TAG constants also during validation?

Yes, I guess so - but I'm looking for validation code that uses constant 0 / 1 for tags/tail-loops and not finding anything. If you can point me where you're looking then I'd be happy to fix?

@acl-cqc
Copy link
Contributor Author

acl-cqc commented Nov 5, 2024

As per discussion on Slack - the other change we could make would be at

let sum_type = Type::new_sum([self.just_inputs.clone(), self.just_outputs.clone()]);
where we could instead do something like

let mut sum_rows = [type_row![], type_row![]];
sum_rows[BREAK_TAG] = self.just_outputs.clone();
sum_rows[CONTINUE_TAG] = self.just_inputs.clone();

but we deem this "not worth it".

@acl-cqc acl-cqc added this pull request to the merge queue Nov 5, 2024
Merged via the queue into main with commit f2ae52e Nov 5, 2024
23 checks passed
@acl-cqc acl-cqc deleted the acl/break_continue_tag branch November 5, 2024 11:52
@hugrbot hugrbot mentioned this pull request Nov 5, 2024
github-merge-queue bot pushed a commit that referenced this pull request Nov 6, 2024
## 🤖 New release
* `hugr`: 0.13.2 -> 0.13.3 (✓ API compatible changes)
* `hugr-core`: 0.13.2 -> 0.13.3 (✓ API compatible changes)
* `hugr-model`: 0.13.2 -> 0.14.0 (⚠️ API breaking changes)
* `hugr-passes`: 0.13.2 -> 0.13.3
* `hugr-cli`: 0.13.2 -> 0.13.3

### ⚠️ `hugr-model` breaking changes

```
--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/enum_variant_added.ron

Failed in:
  variant RegionKind:Module in /tmp/.tmpL1Ich1/hugr/hugr-model/src/v0/mod.rs:390
  variant Operation:DeclareConstructor in /tmp/.tmpL1Ich1/hugr/hugr-model/src/v0/mod.rs:349
  variant Operation:DeclareOperation in /tmp/.tmpL1Ich1/hugr/hugr-model/src/v0/mod.rs:357
```

<details><summary><i><b>Changelog</b></i></summary><p>

## `hugr`
<blockquote>

##
[0.13.3](hugr-v0.13.2...hugr-v0.13.3)
- 2024-11-06

### Bug Fixes

- Insert DFG directly as a funcdefn in `Package::from_hugr`
([#1621](#1621))

### New Features

- `HugrMut::remove_metadata`
([#1619](#1619))
- Operation and constructor declarations in `hugr-model`
([#1605](#1605))
- Add TailLoop::BREAK_TAG and CONTINUE_TAG
([#1626](#1626))
</blockquote>

## `hugr-core`
<blockquote>

##
[0.13.3](hugr-core-v0.13.2...hugr-core-v0.13.3)
- 2024-11-06

### Bug Fixes

- Insert DFG directly as a funcdefn in `Package::from_hugr`
([#1621](#1621))

### New Features

- `HugrMut::remove_metadata`
([#1619](#1619))
- Operation and constructor declarations in `hugr-model`
([#1605](#1605))
- Add TailLoop::BREAK_TAG and CONTINUE_TAG
([#1626](#1626))
</blockquote>

## `hugr-model`
<blockquote>

##
[0.14.0](hugr-model-v0.13.2...hugr-model-v0.14.0)
- 2024-11-06

### New Features

- Operation and constructor declarations in `hugr-model`
([#1605](#1605))
</blockquote>

## `hugr-passes`
<blockquote>

##
[0.13.2](hugr-passes-v0.13.1...hugr-passes-v0.13.2)
- 2024-10-22

### New Features

- make errors more readable with Display impls
([#1597](#1597))
</blockquote>

## `hugr-cli`
<blockquote>

##
[0.13.2](hugr-cli-v0.13.1...hugr-cli-v0.13.2)
- 2024-10-22

### New Features

- Add `Package` definition on `hugr-core`
([#1587](#1587))
- Ensure packages always have modules at the root
([#1589](#1589))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).
@hugrbot hugrbot mentioned this pull request Nov 8, 2024
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.

2 participants