Skip to content

Commit

Permalink
refactor: Move assertValidAssignRhs function in type_check.go
Browse files Browse the repository at this point in the history
  • Loading branch information
omarsy committed Oct 25, 2024
1 parent 89572df commit 7d935f6
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions gnovm/pkg/gnolang/type_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,20 +279,6 @@ func checkValDefineMismatch(n Node) {
panic(fmt.Sprintf("assignment mismatch: %d variable(s) but %d value(s)", numNames, numValues))
}

func assertValidAssignRhs(store Store, last BlockNode, exps Exprs) {
for _, exp := range exps {
switch n := exp.(type) {
case *CallExpr, *TypeAssertExpr, *IndexExpr:
default:
tt := evalStaticTypeOf(store, last, n)
if _, ok := tt.(*TypeType); ok {
tt = evalStaticType(store, last, n)
panic(fmt.Sprintf("%s (type) is not an expression", tt.String()))
}
}
}
}

// Assert that xt can be assigned as dt (dest type).
// If autoNative is true, a broad range of xt can match against
// a target native dt type, if and only if dt is a native type.
Expand Down Expand Up @@ -929,6 +915,20 @@ func assertValidAssignLhs(store Store, last BlockNode, lx Expr) {
}
}

func assertValidAssignRhs(store Store, last BlockNode, exps Exprs) {
for _, exp := range exps {
switch n := exp.(type) {
case *CallExpr, *TypeAssertExpr, *IndexExpr:
default:

Check warning on line 922 in gnovm/pkg/gnolang/type_check.go

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/type_check.go#L921-L922

Added lines #L921 - L922 were not covered by tests
tt := evalStaticTypeOf(store, last, n)
if _, ok := tt.(*TypeType); ok {
tt = evalStaticType(store, last, n)
panic(fmt.Sprintf("%s (type) is not an expression", tt.String()))
}
}
}
}

func kindString(xt Type) string {
if xt != nil {
return xt.Kind().String()
Expand Down

0 comments on commit 7d935f6

Please sign in to comment.