vendor: update HIL

Fixes #10847
Fixes #10778
This commit is contained in:
Mitchell Hashimoto 2016-12-21 11:31:53 -08:00
parent 93f600dbf7
commit 1bae160796
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 31 additions and 23 deletions

View File

@ -119,7 +119,9 @@ func (tc *typeCheckArithmetic) TypeCheck(v *TypeCheck) (ast.Node, error) {
switch tc.n.Op {
case ast.ArithmeticOpLogicalAnd, ast.ArithmeticOpLogicalOr:
return tc.checkLogical(v, exprs)
case ast.ArithmeticOpEqual, ast.ArithmeticOpNotEqual, ast.ArithmeticOpLessThan, ast.ArithmeticOpGreaterThan, ast.ArithmeticOpGreaterThanOrEqual, ast.ArithmeticOpLessThanOrEqual:
case ast.ArithmeticOpEqual, ast.ArithmeticOpNotEqual,
ast.ArithmeticOpLessThan, ast.ArithmeticOpGreaterThan,
ast.ArithmeticOpGreaterThanOrEqual, ast.ArithmeticOpLessThanOrEqual:
return tc.checkComparison(v, exprs)
default:
return tc.checkNumeric(v, exprs)
@ -135,20 +137,11 @@ func (tc *typeCheckArithmetic) checkNumeric(v *TypeCheck, exprs []ast.Type) (ast
mathFunc := "__builtin_IntMath"
mathType := ast.TypeInt
for _, v := range exprs {
exit := true
switch v {
case ast.TypeInt:
mathFunc = "__builtin_IntMath"
mathType = v
case ast.TypeFloat:
// We assume int math but if we find ANY float, the entire
// expression turns into floating point math.
if v == ast.TypeFloat {
mathFunc = "__builtin_FloatMath"
mathType = v
default:
exit = false
}
// We found the type, so leave
if exit {
break
}
}
@ -193,7 +186,6 @@ func (tc *typeCheckArithmetic) checkNumeric(v *TypeCheck, exprs []ast.Type) (ast
}
func (tc *typeCheckArithmetic) checkComparison(v *TypeCheck, exprs []ast.Type) (ast.Node, error) {
if len(exprs) != 2 {
// This should never happen, because the parser never produces
// nodes that violate this.
@ -220,6 +212,22 @@ func (tc *typeCheckArithmetic) checkComparison(v *TypeCheck, exprs []ast.Type) (
)
}
// For non-equality comparisons, we will do implicit conversions to
// integer types if possible. In this case, we need to go through and
// determine the type of comparison we're doing to enable the implicit
// conversion.
if tc.n.Op != ast.ArithmeticOpEqual && tc.n.Op != ast.ArithmeticOpNotEqual {
compareFunc = "__builtin_IntCompare"
compareType = ast.TypeInt
for _, expr := range exprs {
if expr == ast.TypeFloat {
compareFunc = "__builtin_FloatCompare"
compareType = ast.TypeFloat
break
}
}
}
// Verify (and possibly, convert) the args
for i, arg := range exprs {
if arg != compareType {

18
vendor/vendor.json vendored
View File

@ -1613,28 +1613,28 @@
"revisionTime": "2016-11-30T20:58:18Z"
},
{
"checksumSHA1": "xONRNgLDc5OqCUmyDN3iBRKmKB0=",
"checksumSHA1": "2Nrl/YKrmowkRgCDLhA6UTFgYEY=",
"path": "github.com/hashicorp/hil",
"revision": "60db937199ba6f67251aa038cec18ce36a951312",
"revisionTime": "2016-12-09T17:20:46Z"
"revision": "5b8d13c8c5c2753e109fab25392a1dbfa2db93d2",
"revisionTime": "2016-12-21T19:20:42Z"
},
{
"checksumSHA1": "oZ2a2x9qyHqvqJdv/Du3LGeaFdA=",
"path": "github.com/hashicorp/hil/ast",
"revision": "60db937199ba6f67251aa038cec18ce36a951312",
"revisionTime": "2016-12-09T17:20:46Z"
"revision": "5b8d13c8c5c2753e109fab25392a1dbfa2db93d2",
"revisionTime": "2016-12-21T19:20:42Z"
},
{
"checksumSHA1": "P5PZ3k7SmqWmxgJ8Q0gLzeNpGhE=",
"path": "github.com/hashicorp/hil/parser",
"revision": "60db937199ba6f67251aa038cec18ce36a951312",
"revisionTime": "2016-12-09T17:20:46Z"
"revision": "5b8d13c8c5c2753e109fab25392a1dbfa2db93d2",
"revisionTime": "2016-12-21T19:20:42Z"
},
{
"checksumSHA1": "DC1k5kOua4oFqmo+JRt0YzfP44o=",
"path": "github.com/hashicorp/hil/scanner",
"revision": "60db937199ba6f67251aa038cec18ce36a951312",
"revisionTime": "2016-12-09T17:20:46Z"
"revision": "5b8d13c8c5c2753e109fab25392a1dbfa2db93d2",
"revisionTime": "2016-12-21T19:20:42Z"
},
{
"path": "github.com/hashicorp/logutils",