ergoplatform / ergoplatform/sigma-rust
Incorrect type variables in some `SMethodDesc` instances
- Dominant language
- Rust
- Stars
- 78
- Forks
- 63
- Avg merge
- 22h 5m
- Merged PRs (30d)
- 3
Description
Found while expanding scala JIT test suite examples for issue #633.
E.g. consider the `Coll.zip` method.
In scala the implementation is here: https://github.com/ScorexFoundation/sigmastate-interpreter/blob/0c5c5b515ccb452536e440469b56d763d5ba30ec/sigmastate/src/main/scala/sigmastate/types.scala#L1658
Note the use of the `IV` and `OV` type variables.
Now on rust the `T` type variable is used: https://github.com/ergoplatform/sigma-rust/blob/7f44eceb3ebd0b008551437174d78f925493a927/ergotree-ir/src/types/scoll.rs#L84-L89
This breaks my proc-macro test which is directly lifted from Scala:
```rust
#[test]
fn test_method_call_zip_0() {
// { (x: Coll[Box]) => x.zip(x) }
let _ = ergo_tree!(
FuncValue(
Vector((1, SCollectionType(SBox))),
MethodCall.typed[Value[SCollection[STuple]]](
ValUse(1, SCollectionType(SBox)),
SCollection.getMethodByName("zip").withConcreteTypes(
Map(STypeVar("IV") -> SBox, STypeVar("OV") -> SBox)
),
Vector(ValUse(1, SCollectionType(SBox))),
Map()
)
)
);
}
```
This gives test gives the following error:
```
thread 'test_method_call_zip_0' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidArgumentError("MethodCall: expected types [SColl(STypeVar(\"T\")), SColl(SBox)] do not match provided obj and args types [SColl(SBox), SColl(SBox)]")'
```
There are others with similar problems like `Coll.patch`.
Contributor guide
Assessment
This issue has not been assessed yet.