Bug in Array.tabulateVar()

I discovered that the Array.tabulateVar function loops over the index 0 twice. This unexpected behaviour may cause issues in developers’ code.

moc version: 0.10.1

Reproduce with:

    Array.tabulateVar(5, func(i: Nat): Nat { 
        Debug.print(debug_show(i)); 
        i;
    });
0, 0, 1, 2, 3, 4, 5
3 Likes

Thank you for the report! Should be fixed here: fix tabulateVar by chenyan-dfinity · Pull Request #596 · dfinity/motoko-base · GitHub

3 Likes