Skip to content

fix!: Change array result ops signature to return array result #888

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

tatiana-s
Copy link
Contributor

Needed for CQCL/guppylang#981

BREAKING CHANGE: ResultOpDef::ArrBool, ResultOpDef::ArrInt, ResultOpDef::ArrUInt and ResultOpDef::ArrF64 signatures now return array results

@tatiana-s tatiana-s requested a review from a team as a code owner May 27, 2025 14:41
@tatiana-s tatiana-s requested a review from lmondada May 27, 2025 14:41
Copy link

codecov bot commented May 27, 2025

Codecov Report

Attention: Patch coverage is 97.14286% with 1 line in your changes missing coverage. Please review.

Project coverage is 80.69%. Comparing base (1895f68) to head (f799acf).

Files with missing lines Patch % Lines
tket2-hseries/src/extension/result.rs 96.77% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #888      +/-   ##
==========================================
+ Coverage   80.66%   80.69%   +0.02%     
==========================================
  Files          88       88              
  Lines       10711    10731      +20     
  Branches    10437    10457      +20     
==========================================
+ Hits         8640     8659      +19     
  Misses       1492     1492              
- Partials      579      580       +1     
Flag Coverage Δ
python 81.75% <ø> (ø)
rust 80.66% <97.14%> (+0.02%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@lmondada lmondada left a comment

Choose a reason for hiding this comment

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

I don't know the downstream implications of making breaking changes to tket2, but this seems necessary and I'm assuming other people (e.g. Seyon) know this is required. There's already a breaking change in main anyways #854

So LGTM!

PolyFuncType::new(
[vec![TypeParam::String], self.type_params()].concat(),
Signature::new(self.arg_type(), vec![self.arg_type()]),
)
Copy link
Contributor

@lmondada lmondada May 29, 2025

Choose a reason for hiding this comment

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

Remove the vec![] for consistency (handled by Into).

Consider also just defining let output = if ... else ...; and then moving the shared code for the returned value after the conditional. Keeps the branched code shorter and removes duplication.

Suggested change
)
Signature::new(self.arg_type(), self.arg_type()),

Copy link
Contributor

Choose a reason for hiding this comment

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

wrong line, this edit is for 168

[vec![TypeParam::String], self.type_params()].concat(),
Signature::new(self.arg_type(), type_row![]),
if self.is_array_result_op() {
// Arrays need to be returned to preserve no-implicit copy guarantees.
Copy link
Contributor

Choose a reason for hiding this comment

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

There is not really a "no-implicit copy guarantee" in tket2 -- that's a guppy thing, right? I'm not sure how to phrase this comment in a way that makes sense for tket2. Maybe something along the lines of "Do not consume input arrays to allow linearity"?

@tatiana-s tatiana-s changed the title feat!: Change array result ops signature to return array result fix!: Change array result ops signature to return array result Jun 10, 2025
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