Open
Description
Describe the bug
Nargo 1.0.0 beta fails to compile merkle tree example. This is problematic because the 1.0.0 beta is the default version installed by noirup. This problem can be avoided by running noirup -v 0.39.0
To Reproduce
Install the latest noir version using the quick-start instructions. Take the demo code from the merkle trees package and attempt to compile.
Expected behavior
Circuit compiles.
Screenshots
Error output
error: expected type SparseMerkleTree<T>, found type ()
ββ /Users/chance/nargo/github.com/privacy-scaling-explorations/zk-kit.noir/main/packages/merkle-trees/src/types.nr:7:12
β
7 β pub fn default(root: T, leaf_hasher: fn([T; 3]) -> T, hasher: fn([T; 2]) -> T) -> Self {}
β ------- ---- expected SparseMerkleTree<T> because of return type
β β
β () returned here
β
= implicitly returns `()` as its body has no tail or `return` expression
error: Expected type fn([Field; 3]) -> Field, found type fn([T; 3]) -> T
ββ /Users/chance/nargo/github.com/privacy-scaling-explorations/zk-kit.noir/main/packages/merkle-trees/src/types.nr:23:23
β
23 β Self::from(0, leaf_hasher, hasher)
β -----------
β
error: Expected type fn([Field; 2]) -> Field, found type fn([T; 2]) -> T
ββ /Users/chance/nargo/github.com/privacy-scaling-explorations/zk-kit.noir/main/packages/merkle-trees/src/types.nr:23:36
β
23 β Self::from(0, leaf_hasher, hasher)
β ------
β
error: Only struct types can be used in constructor expressions
ββ /Users/chance/nargo/github.com/privacy-scaling-explorations/zk-kit.noir/main/packages/merkle-trees/src/types.nr:29:9
β
29 β Self { root, hasher }
β ---- _ has no fields to construct it with
β
error: Could not resolve 'T' in path
ββ /Users/chance/nargo/github.com/privacy-scaling-explorations/zk-kit.noir/main/packages/merkle-trees/src/types.nr:46:20
β
46 β Self::from(T::default(), hasher)
β -
β
Aborting due to 5 previous errors
main.nr
:
use trees::merkle::MerkleTree;
use std::hash::poseidon;
use trees::types::MT_Creator;
use trees::types::Modifier;
fn main(entry: Field, paths: [Field; 0]) -> pub Field {
let mut mt = MerkleTree::new(poseidon::bn254::hash_2);
mt.add(entry, 0, paths);
//mt.membership(entry, 0, paths);
0
}
#[test]
fn test_main() {
//let _ = main(1, 2);
// Uncomment to make test fail
// main(1, 1);
}
Technologies (please complete the following information):
nargo --version
nargo version = 1.0.0-beta.2
noirc version = 1.0.0-beta.2+1a2a08cbcb68646ff1aaef383cfc1798933c1355
(git version hash: 1a2a08cbcb68646ff1aaef383cfc1798933c1355, is dirty: false)
Additional context
Add any other context about the problem here.