lang: unification: Fix panic in struct/func cmp of partials

This was discovered by user aequitas. I modified his patch slightly, and
added some comments and a test.
This commit is contained in:
James Shubin
2018-02-27 16:39:10 -05:00
parent df1e50e599
commit ff69a82b57
2 changed files with 45 additions and 0 deletions

View File

@@ -473,6 +473,41 @@ func TestUnification1(t *testing.T) {
fail: true,
})
}
{
//test "t1" {
// stringptr => getenv("GOPATH", "bug"), # bad (two args vs. one)
//}
expr := &ExprCall{
Name: "getenv",
Args: []interfaces.Expr{
&ExprStr{
V: "GOPATH",
},
&ExprStr{
V: "bug",
},
},
}
stmt := &StmtProg{
Prog: []interfaces.Stmt{
&StmtRes{
Kind: "test",
Name: &ExprStr{V: "t1"},
Fields: []*StmtResField{
{
Field: "stringptr",
Value: expr,
},
},
},
},
}
values = append(values, test{
name: "function, wrong arg count",
ast: stmt,
fail: true,
})
}
for index, test := range values { // run all the tests
t.Run(fmt.Sprintf("test #%d (%s)", index, test.name), func(t *testing.T) {