fix: handle type for unary expression (#108)
This commit is contained in:
committed by
Ludovic Fernandez
parent
c8693ba672
commit
0fb2370c33
@@ -218,6 +218,14 @@ func TestEvalCompositeArray0(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvalUnary0(t *testing.T) {
|
||||
i := interp.New(interp.Opt{})
|
||||
v := evalCheck(t, i, `a := -1`)
|
||||
if expected := "-1"; fmt.Sprintf("%v", v) != expected {
|
||||
t.Fatalf("Expected %v, got %v", expected, v)
|
||||
}
|
||||
}
|
||||
|
||||
func evalCheck(t *testing.T, i *interp.Interpreter, src string) reflect.Value {
|
||||
t.Helper()
|
||||
|
||||
|
||||
@@ -193,6 +193,9 @@ func nodeType(interp *Interpreter, scope *Scope, n *Node) (*Type, error) {
|
||||
err = n.cfgError("missign support for type %T", n.val)
|
||||
}
|
||||
|
||||
case UnaryExpr:
|
||||
t, err = nodeType(interp, scope, n.child[0])
|
||||
|
||||
case BinaryExpr:
|
||||
t, err = nodeType(interp, scope, n.child[0])
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user