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

#[contracttype] doesn't support tuple fields #1124

Open
brson opened this issue Oct 27, 2023 · 1 comment
Open

#[contracttype] doesn't support tuple fields #1124

brson opened this issue Oct 27, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@brson
Copy link
Contributor

brson commented Oct 27, 2023

What version are you using?

v20.0.0-rc1
4639f5a

What did you do?

        #[contracttype]
        #[derive(Clone, Debug, Eq, PartialEq)]
        struct Tuples {
            tuple: (u32, u32),
        }

What did you expect to see?

Compile.

What did you see instead?

   Compiling soroban-sdk v20.0.0-rc2 (/home/azureuser/data/stellar/rs-soroban-sdk/soroban-sdk)
error[E0277]: the trait bound `soroban_env_host::xdr::ScVal: From<&(u32, u32)>` is not satisfied
    --> soroban-sdk/src/arbitrary.rs:1547:9
     |
1547 |         #[contracttype]
     |         ^^^^^^^^^^^^^^^ the trait `From<&(u32, u32)>` is not implemented for `soroban_env_host::xdr::ScVal`
     |
     = help: the following other types implement trait `From<T>`:
               <soroban_env_host::xdr::ScVal as From<bool>>
               <soroban_env_host::xdr::ScVal as From<i32>>
               <soroban_env_host::xdr::ScVal as From<i64>>
               <soroban_env_host::xdr::ScVal as From<i128>>
               <soroban_env_host::xdr::ScVal as From<u32>>
               <soroban_env_host::xdr::ScVal as From<u64>>
               <soroban_env_host::xdr::ScVal as From<u128>>
               <soroban_env_host::xdr::ScVal as From<ScValObject>>
             and 15 others
     = note: required for `&(u32, u32)` to implement `Into<soroban_env_host::xdr::ScVal>`
     = note: required for `soroban_env_host::xdr::ScVal` to implement `TryFrom<&(u32, u32)>`
     = note: required for `&(u32, u32)` to implement `TryInto<soroban_env_host::xdr::ScVal>`
     = note: this error originates in the attribute macro `contracttype` (in Nightly builds, run with -Z macro-backtrace for more info)

This is also true of tuple-structs and enums.

@brson brson added the bug Something isn't working label Oct 27, 2023
@brson
Copy link
Contributor Author

brson commented Oct 27, 2023

Found while fixing #1053

github-merge-queue bot pushed a commit that referenced this issue Oct 28, 2023
### What

Implement SorobanArbitrary for tuples of up to 12 elements.

### Why

This was accidentally omitted previously. Fixes
#1053

### Known limitations

Using tuples in struct fields is still blocked on
#1124
brson added a commit to brson/rs-soroban-sdk that referenced this issue Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
@brson and others