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

Can't infer type. #100

Open
djm07073 opened this issue Jul 31, 2024 · 3 comments
Open

Can't infer type. #100

djm07073 opened this issue Jul 31, 2024 · 3 comments

Comments

@djm07073
Copy link
Contributor

djm07073 commented Jul 31, 2024

It looks like it have the same issue

struct Weight has copy, drop, store {
        bridge_id: u64,
        weight: Decimal128,
}

fun remove_vote(
        proposal: &mut Proposal,
        voting_power_used: u64,
        weights: vector<Weight>
    ) {
        let weight_sum = decimal128::zero();
        vector::for_each_ref(
            &weights,
            |w| {
                weight_sum = decimal128::add(&weight_sum, &w.weight); <---- cannot infer type. Unbound field 'weight'""
            }
        );
}
@Vritra4
Copy link
Contributor

Vritra4 commented Aug 1, 2024

link seems broken and invalid

@djm07073
Copy link
Contributor Author

djm07073 commented Aug 1, 2024

now, i fix it

@djm07073
Copy link
Contributor Author

djm07073 commented Aug 9, 2024

the code below builds successfully; a temporary workaround to avoid type inference errors.

inline fun use_user_vesting(_value: UserVesting) {} --> inline function to use explicit type

vector::for_each(
            user_vestings_cache, --> vector<UserVesting>
            |vesting| {
                use_user_vesting(vesting);  --> explicit type of UserVesting
                table::upsert(
                    user_vestings,
                    table_key::encode_u64(vesting.start_stage),
                    vesting
                );
                // .... other code logic
        );

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