-
Notifications
You must be signed in to change notification settings - Fork 7
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!: Merge Value
into Const
#881
Conversation
Value
into Const
Value
into Const
} | ||
|
||
/// Constant Sum over units, used as branching values. | ||
pub fn unit_sum(tag: usize, size: u8) -> Result<Self, ConstTypeError> { |
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.
This only returns an Err
if tag >= size
.
I'm undecided on whether panicking instead, as every caller just unwraps it immediately.
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.
I prefer using Result
over panicking here, because other similar functions (e.g. function
above) do. It's a public function so we can't say anything about every caller.
7de0332
to
c9976c7
Compare
c9976c7
to
76f18e5
Compare
Added an ad-hoc |
I think the serialisation schema should be changing because the serialisation of const nodes has changed? We have already bumped the serialisation version to V1 since the last release, so it is fine to change the V1 schema. If we hadn't bumped since the last release this would necessitate bumping. |
Yes, here's how the new encoding looks for an (extension) {
"v": "Extension",
"c": {
"c": "ConstUsize",
"value": 257
}
} And for a {
"v": "Sum",
"tag": 0,
"values": [
{
"v": "Extension",
"c": {
"c": "ConstUsize",
"value": 257
}
},
{
"v": "Extension",
"c": {
"c": "CustomSerialized",
"typ": {
"t": "Opaque",
"extension": "arithmetic.float.types",
"id": "float64",
"args": [],
"bound": "C"
},
"value": 5.1,
"extensions": [
"arithmetic.float.types"
]
}
}
],
"typ": {
"s": "General",
"rows": [
[
{
"t": "I"
},
{
"t": "Opaque",
"extension": "arithmetic.float.types",
"id": "float64",
"args": [],
"bound": "C"
}
],
[]
]
}
} |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #881 +/- ##
==========================================
+ Coverage 85.49% 85.62% +0.12%
==========================================
Files 78 78
Lines 14455 14397 -58
Branches 14455 14397 -58
==========================================
- Hits 12359 12327 -32
+ Misses 1459 1436 -23
+ Partials 637 634 -3 ☔ View full report in Codecov by Sentry. |
I updated the serialization schema manually (merging the json generated by CQCL/guppylang#172 with the local changes). |
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.
Awesome, just a few nits
} | ||
|
||
/// Constant Sum over units, used as branching values. | ||
pub fn unit_sum(tag: usize, size: u8) -> Result<Self, ConstTypeError> { |
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.
I prefer using Result
over panicking here, because other similar functions (e.g. function
above) do. It's a public function so we can't say anything about every caller.
Const
was a struct with aValue
+ a defined type. In practice, the onlyValue
that couldn't report its full type wasSum
.This PR merges the two structs, adding an explicit
sum_type
to the sum variant.Also:
Type::check_type
, as this is now unnecessary.SumTypeError
is not aConstTypeError
is not aCustomCheckFailure
.CustomConst
is now accessible from::ops::custom
instead of::values
.This change breaks the serialisation format.
Closes #874.
BREAKING CHANGE: Removed
Value
, merged intoConst