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

Incorrect type variables in some SMethodDesc instances #642

Open
kettlebell opened this issue Oct 16, 2022 · 3 comments
Open

Incorrect type variables in some SMethodDesc instances #642

kettlebell opened this issue Oct 16, 2022 · 3 comments
Assignees

Comments

@kettlebell
Copy link
Collaborator

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:

static ref ZIP_METHOD_DESC: SMethodDesc = SMethodDesc {
method_id: ZIP_METHOD_ID,
name: "zip",
tpe: SFunc::new(
vec![
SType::SColl(SType::STypeVar(STypeVar::t()).into()),

This breaks my proc-macro test which is directly lifted from Scala:

#[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.

@greenhat
Copy link
Member

greenhat commented Oct 18, 2022

Good catch! I was probably writing them without putting too many thoughts into keeping type var names in sync with Scala.

@kettlebell
Copy link
Collaborator Author

I'll take care of cleaning this up!

@kettlebell kettlebell self-assigned this Oct 18, 2022
@greenhat
Copy link
Member

Thank you!

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

No branches or pull requests

2 participants