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

[Bug][move compiler v2] receiver-style syntax doesn’t work correctly with generic functions with single argument #15582

Open
igor-aptos opened this issue Dec 12, 2024 · 1 comment
Labels
bug Something isn't working compiler-v2

Comments

@igor-aptos
Copy link
Contributor

🐛 Bug

It looks like receiver-style syntax doesn’t work correctly with generic functions with single argument (occurs with Any and Object functions)
Example:
this works:

        let value = pack(S { x: 22 });
        assert!(unpack<S>(value) == S { x: 22 }, 2);

this doesn’t:

        let value = pack(S { x: 22 });
        assert!(value.unpack<S>() == S { x: 22 }, 2);

With error:

error: field `unpack` not declared in struct `Any`
   ┌─ aptos-move/framework/aptos-framework/../aptos-stdlib/sources/any.move:62:17
   │
62 │         assert!(value.unpack<S>() == S { x: 22 }, 2);
   │                 ^^^^^

error: cannot use `S` with an operator which expects a value of type `integer`
   ┌─ aptos-move/framework/aptos-framework/../aptos-stdlib/sources/any.move:62:30
   │
62 │         assert!(value.unpack<S>() == S { x: 22 }, 2);
   │                              ^

error: no arguments provided for pack, expected 1
   ┌─ aptos-move/framework/aptos-framework/../aptos-stdlib/sources/any.move:62:30
   │
62 │         assert!(value.unpack<S>() == S { x: 22 }, 2);
   │                              ^

error: cannot use `()` with an operator which expects a value of type `integer`
   ┌─ aptos-move/framework/aptos-framework/../aptos-stdlib/sources/any.move:62:32
   │
62 │         assert!(value.unpack<S>() == S { x: 22 }, 2);

To reproduce

this line doesn't compile - ae8cfde - when using move 2 compiler / features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler-v2
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants
@igor-aptos and others