Skip to content

Commit

Permalink
fix!: Make list length op give back the list (#1547)
Browse files Browse the repository at this point in the history
Fixes #1543.

BREAKING CHANGE: The `length` op in the std `collections` extensions now
also returns the list.
  • Loading branch information
mark-koch authored Oct 3, 2024
1 parent ea8e818 commit cf31698
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hugr-core/src/std_extensions/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl ListOp {
vec![l, either_type(e, Type::UNIT).into()],
)
.into(),
length => self.list_polytype(vec![l], vec![USIZE_T]).into(),
length => self.list_polytype(vec![l.clone()], vec![l, USIZE_T]).into(),
}
}

Expand Down
16 changes: 16 additions & 0 deletions hugr-py/src/hugr/std/_json_defs/collections.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@
}
],
"output": [
{
"t": "Opaque",
"extension": "collections",
"id": "List",
"args": [
{
"tya": "Type",
"ty": {
"t": "V",
"i": 0,
"b": "A"
}
}
],
"bound": "A"
},
{
"t": "I"
}
Expand Down
16 changes: 16 additions & 0 deletions specification/std_extensions/collections.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@
}
],
"output": [
{
"t": "Opaque",
"extension": "collections",
"id": "List",
"args": [
{
"tya": "Type",
"ty": {
"t": "V",
"i": 0,
"b": "A"
}
}
],
"bound": "A"
},
{
"t": "I"
}
Expand Down

0 comments on commit cf31698

Please sign in to comment.