Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: custom boolean types in conditional statements #2147

Merged
merged 12 commits into from
Jun 19, 2024
4 changes: 4 additions & 0 deletions gnovm/cmd/gno/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ func TestRunApp(t *testing.T) {
args: []string{"run", "-debug-addr", "invalidhost:17538", "../../tests/integ/debugger/sample.gno"},
errShouldContain: "listen tcp: lookup invalidhost",
},
{
args: []string{"run", "../../tests/integ/invalid_assign/main.gno"},
recoverShouldContain: "cannot use bool as main.C without explicit conversion",
},
// TODO: a test file
// TODO: args
// TODO: nativeLibs VS stdlibs
Expand Down
25 changes: 25 additions & 0 deletions gnovm/tests/files/for19.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

func main() {
v := T
i := 0
for v {
if i > 2 {
break
}
println(i)
i++
}
}

type C bool

const (
F C = false
T C = true
)

// Output:
// 0
// 1
// 2
18 changes: 18 additions & 0 deletions gnovm/tests/files/if8.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

func main() {
v := T
if v {
println("true")
}
}

type C bool

const (
F C = false
T C = true
)

// Output:
// true
16 changes: 16 additions & 0 deletions gnovm/tests/integ/invalid_assign/main.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This should result in a compilation error for assigning a bool to a custom bool type without conversion

package main

func main() {
b := true
var v C = b
fmt.Println(v)
}

type C bool

const (
F C = false
T C = true
)
Loading