Convert [Nat8] to Text, Cannot mix BigInt and other types, use explicit conversions

Hello
i’ve been using motoko for my project these days. today i wrote a function in a actor like this

public shared func nat8Arr2Text(arr: [Nat8]): async Text {
        var res: Text = "";
        var toIter: Iter.Iter<Nat8> = Array.vals(arr);
        for(val in toIter) {
            res := res # Nat8.toText(val);
        };
        res
    };

it compiled and no error came out. but when i open Candid UI for test in local network by feeding paramters. there came out a error:
Cannot mix BigInt and other types, use explicit conversions
Screenshot from 2022-01-13 22-38-02

Is there anyone knowing what happened here?
much thanks.

Hi,

The the size of array is Nat and the UI can’t mix javascript Number and BigInt as you can see with the playground below if you use only Nat it can be called from UI. If you call your function from cli or from javascript invocation it will works.

got the reason, thanks for the experiment :slight_smile:

It’s a valid bug to point out for the Candid UI though, so thanks for sharing!

1 Like