Problem with Prim.nat64ToNat32

I am trying to use a method I found in Zhenya Usenko Github:

This is the method (hash function from Nat to Nat32):

func hashNat(key: Nat): Nat32 {
  var hash = Prim.intToNat64Wrap(key);

  hash := hash >> 30 ^ hash *% 0xbf58476d1ce4e5b9;
  hash := hash >> 27 ^ hash *% 0x94d049bb133111eb;

  Prim.nat64ToNat32(hash >> 31 ^ hash & 0x3fffffff);   // <---- ERROR
};

When I try to dfx generate, I get the error:

type error [M0072], field nat64ToNat32 does not exist in type ...

I looked inside prim.mo, and this method exists. Why is the dfx generate giving me this error?

You may need to make sure you are using the latest moc. You might have to download it manually and put it in your cache/dfx0.15.1 directory(don’t forget to try to manually run it).

1 Like