@ -9,7 +9,6 @@ import (
"github.com/apparentlymart/go-textseg/textseg"
"github.com/hashicorp/hcl2/hcl"
"github.com/zclconf/go-cty/cty"
"github.com/zclconf/go-cty/cty/convert"
)
type parser struct {
@ -236,10 +235,18 @@ func (p *parser) finishParsingBodyAttribute(ident Token, singleLine bool) (Node,
end := p . Peek ( )
if end . Type != TokenNewline && end . Type != TokenEOF {
if ! p . recovery {
summary := "Missing newline after argument"
detail := "An argument definition must end with a newline."
if end . Type == TokenComma {
summary = "Unexpected comma after argument"
detail = "Argument definitions must be separated by newlines, not commas. " + detail
}
diags = append ( diags , & hcl . Diagnostic {
Severity : hcl . DiagError ,
Summary : "Missing newline after argument" ,
Detail : "An argument definition must end with a newline." ,
Summary : summary ,
Detail : detail ,
Subject : & end . Range ,
Context : hcl . RangeBetween ( ident . Range , end . Range ) . Ptr ( ) ,
} )
@ -1040,11 +1047,10 @@ func (p *parser) parseExpressionTerm() (Expression, hcl.Diagnostics) {
}
func ( p * parser ) numberLitValue ( tok Token ) ( cty . Value , hcl . Diagnostics ) {
// We'll lean on the cty converter to do the conversion, to ensure that
// the behavior is the same as what would happen if converting a
// non-literal string to a number.
numStrVal := cty . StringVal ( string ( tok . Bytes ) )
numVal , err := convert . Convert ( numStrVal , cty . Number )
// The cty.ParseNumberVal is always the same behavior as converting a
// string to a number, ensuring we always interpret decimal numbers in
// the same way.
numVal , err := cty . ParseNumberVal ( string ( tok . Bytes ) )
if err != nil {
ret := cty . UnknownVal ( cty . Number )
return ret , hcl . Diagnostics {