Support driver config fields being set to nil (#5391)

To pick up https://github.com/hashicorp/hcl2/pull/90
This commit is contained in:
Mahmood Ali
2019-03-05 21:47:06 -05:00
committed by GitHub
parent d8323724ef
commit 32623ce3ee
5 changed files with 125 additions and 7 deletions

View File

@@ -1242,7 +1242,13 @@ func (p *parser) parseObjectCons() (Expression, hcl.Diagnostics) {
panic("parseObjectCons called without peeker pointing to open brace")
}
if forKeyword.TokenMatches(p.Peek()) {
// We must temporarily stop looking at newlines here while we check for
// a "for" keyword, since for expressions are _not_ newline-sensitive,
// even though object constructors are.
p.PushIncludeNewlines(false)
isFor := forKeyword.TokenMatches(p.Peek())
p.PopIncludeNewlines()
if isFor {
return p.finishParsingForExpr(open)
}
@@ -1377,6 +1383,8 @@ func (p *parser) parseObjectCons() (Expression, hcl.Diagnostics) {
}
func (p *parser) finishParsingForExpr(open Token) (Expression, hcl.Diagnostics) {
p.PushIncludeNewlines(false)
defer p.PopIncludeNewlines()
introducer := p.Read()
if !forKeyword.TokenMatches(introducer) {
// Should never happen if callers are behaving

View File

@@ -499,6 +499,8 @@ func (e *expression) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
return cty.DynamicVal, diags
}
return cty.ObjectVal(attrs), diags
case *nullVal:
return cty.NullVal(cty.DynamicPseudoType), nil
default:
// Default to DynamicVal so that ASTs containing invalid nodes can
// still be partially-evaluated.