gobra
gobra copied to clipboard
Viper type error when encoding struct constructor with nil values
The following two inputs lead to a type-error in the resulting Viper encoding (detectable via --checkConsistency) or, if undetected, result in a crash of Silicon / the prover.
package ex1
type PrefixTree struct {
Value *[32]byte
Left *PrefixTree
}
func test() (tree *PrefixTree) {
tree = &PrefixTree{nil, nil}
return
}
package ex2
type PrefixLeaf struct {
Vrf_output [32]byte
Commitment [32]byte
}
type PrefixTree struct {
Value *[32]byte
Leaf *PrefixLeaf
}
func test() (tree *PrefixTree) {
tree = &PrefixTree{nil, nil}
return
}
Observations:
-
PrefixTreeneeds at least 2 struct fields -
&PrefixTree{nil, nil}is causing the error. The error does not appear when using&PrefixTree{}instead
I thought this is a fairly recent regression but I can't find the commit on which it worked:
- Reproducible on latest
mastercommit: ac4a94b21f2f3e55bd8c7299ae9fbc422e999d41 - Reproducible on latest
hyperGobracommit: 151a1852991acd9966db402b9e4819b1bbe9b1c0 - Reproducible on
hyperGobracommit 8facab51220570ff88f72e71e794bcb336208e47