Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

[Bug]assert! can't recognize the user-defined fun return type #1046

Open
delvindonn opened this issue May 7, 2023 · 0 comments
Open

[Bug]assert! can't recognize the user-defined fun return type #1046

delvindonn opened this issue May 7, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@delvindonn
Copy link

🐛 Bug

To reproduce

Code snippet to reproduce

    public fun contains<Value: drop,store>(
        set: &SimpleSet<Value>,
        value: Value,
    ): bool {
        let len = vector::length(&set.data);
        let i = 0;
        while(i < len){
            let v = vector::borrow(&set.data, i);
            if (v == &value){
                return true
            };
            i = i + 1;
        };
        false
    }

    #[test]
    public fun add_remove_many(){
        let set = create<u64>();
        
        assert!(length(&set) == 0,0);
        assert!(contains(&set, 11),1);
        // add(&mut set, 11);
        // assert!(length(&set) == 1,2);
        // assert!(contains_v(&set, 11),3);
        // assert!(*at(&set, 0) == 11,4);
        // add(&mut set, 12);
        // add(&mut set, 13);
        // add(&mut set, 14);
        // add(&mut set, 15);
    }

Stack trace/error message

   assert!(contains(&set, 11),1);
   │                 ^^^^^^^^^^^^^^^^^^ Could not infer this type. Try adding an annotation

Expected Behavior

i can't understand why it can't infer type

System information

Please complete the following information:

Additional context

Add any other context about the problem here.

@delvindonn delvindonn added the bug Something isn't working label May 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant