Merge pull request #22137 from hashicorp/jbardin/update-hcl2

update hcl2
This commit is contained in:
James Bardin 2019-07-18 20:55:36 -04:00 committed by GitHub
commit 4b79f85a25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 3 deletions

2
go.mod
View File

@ -64,7 +64,7 @@ require (
github.com/hashicorp/go-version v1.1.0
github.com/hashicorp/golang-lru v0.5.0 // indirect
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f
github.com/hashicorp/hcl2 v0.0.0-20190702185634-5b39d9ff3a9a
github.com/hashicorp/hcl2 v0.0.0-20190719002611-618463aa7958
github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590
github.com/hashicorp/logutils v1.0.0
github.com/hashicorp/memberlist v0.1.0 // indirect

2
go.sum
View File

@ -218,6 +218,8 @@ github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh
github.com/hashicorp/hcl2 v0.0.0-20181208003705-670926858200/go.mod h1:ShfpTh661oAaxo7VcNxg0zcZW6jvMa7Moy2oFx7e5dE=
github.com/hashicorp/hcl2 v0.0.0-20190702185634-5b39d9ff3a9a h1:1KfDwkIXrxrfMpqwuW//ujObiYNuR2DqaETSK2NB8Ug=
github.com/hashicorp/hcl2 v0.0.0-20190702185634-5b39d9ff3a9a/go.mod h1:FSQTwDi9qesxGBsII2VqhIzKQ4r0bHvBkOczWfD7llg=
github.com/hashicorp/hcl2 v0.0.0-20190719002611-618463aa7958 h1:tWvka6jPDo/2jqd06ErHWiWlrXZDczD63dTfBw2wxi0=
github.com/hashicorp/hcl2 v0.0.0-20190719002611-618463aa7958/go.mod h1:FSQTwDi9qesxGBsII2VqhIzKQ4r0bHvBkOczWfD7llg=
github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590 h1:2yzhWGdgQUWZUCNK+AoO35V+HTsgEmcM4J9IkArh7PI=
github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590/go.mod h1:n2TSygSNwsLJ76m8qFXTSc7beTb+auJxYdqrnoqwZWE=
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=

View File

@ -473,7 +473,7 @@ func (e *ConditionalExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostic
falseResult, falseDiags := e.FalseResult.Value(ctx)
var diags hcl.Diagnostics
var resultType cty.Type
resultType := cty.DynamicPseudoType
convs := make([]convert.Conversion, 2)
switch {
@ -481,12 +481,21 @@ func (e *ConditionalExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostic
// literal null in the config), we know that it can convert to the expected
// type of the opposite case, and we don't need to speculatively reduce the
// final result type to DynamicPseudoType.
// If we know that either Type is a DynamicPseudoType, we can be certain
// that the other value can convert since it's a pass-through, and we don't
// need to unify the types. If the final evaluation results in the dynamic
// value being returned, there's no conversion we can do, so we return the
// value directly.
case trueResult.RawEquals(cty.NullVal(cty.DynamicPseudoType)):
resultType = falseResult.Type()
convs[0] = convert.GetConversionUnsafe(cty.DynamicPseudoType, resultType)
case falseResult.RawEquals(cty.NullVal(cty.DynamicPseudoType)):
resultType = trueResult.Type()
convs[1] = convert.GetConversionUnsafe(cty.DynamicPseudoType, resultType)
case trueResult.Type() == cty.DynamicPseudoType, falseResult.Type() == cty.DynamicPseudoType:
// the final resultType type is still unknown
// we don't need to get the conversion, because both are a noop.
default:
// Try to find a type that both results can be converted to.

2
vendor/modules.txt vendored
View File

@ -326,7 +326,7 @@ github.com/hashicorp/hcl/hcl/scanner
github.com/hashicorp/hcl/hcl/strconv
github.com/hashicorp/hcl/json/scanner
github.com/hashicorp/hcl/json/token
# github.com/hashicorp/hcl2 v0.0.0-20190702185634-5b39d9ff3a9a
# github.com/hashicorp/hcl2 v0.0.0-20190719002611-618463aa7958
github.com/hashicorp/hcl2/hcl
github.com/hashicorp/hcl2/hcl/hclsyntax
github.com/hashicorp/hcl2/hcldec