Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
omarsy committed Nov 26, 2024
1 parent 194883a commit 13136c5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
9 changes: 9 additions & 0 deletions gnovm/pkg/gnolang/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -2436,6 +2436,15 @@ func parseAssignFromExprList(
for i := 0; i < numNames; i++ {
sts[i] = nt
}
if isConst {
if xnt, ok := nt.(*NativeType); ok {
nt = go2GnoBaseType(xnt.Type)
}

Check warning on line 2442 in gnovm/pkg/gnolang/preprocess.go

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/preprocess.go#L2441-L2442

Added lines #L2441 - L2442 were not covered by tests

if _, ok := baseOf(nt).(PrimitiveType); !ok {
panic(fmt.Sprintf("invalid constant type %s", nt.String()))
}
}
// Convert if const to nt.
for i := range valueExprs {
checkOrConvertType(store, bn, &valueExprs[i], nt, false)
Expand Down
2 changes: 1 addition & 1 deletion gnovm/tests/files/const30.gno
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ func main() {
}

// Error:
// main/files/const30.gno:10:8: v<VPBlock(3,0)>() (no value) used as value
// main/files/const30.gno:10:8: v<VPBlock(3,0)> (no value) used as value
2 changes: 1 addition & 1 deletion gnovm/tests/files/const37_native.gno
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ func main() {
}

// Error:
// main/files/const37_native.gno:6:8: time<VPBlock(2,0)>.UTC (variable of type gonative{*time.Location}) is not constant
// main/files/const37_native.gno:6:8: time<VPBlock(2,0)>.UTC (variable of type *time.Location) is not constant
8 changes: 4 additions & 4 deletions gnovm/tests/files/const38.gno
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package main

import "net"
import "std"

func main() {
v := net.TCPAddr{}
const c = v.IP
v := std.Coin{}
const c = v.Denom
}

// Error:
// main/files/const38.gno:7:8: v<VPBlock(1,0)>.IP (variable of type gonative{net.TCPAddr}) is not constant
// main/files/const38.gno:7:8: v<VPBlock(1,0)>.Denom (variable of type std.Coin) is not constant

0 comments on commit 13136c5

Please sign in to comment.