MCPcopy
hub / github.com/hashicorp/hcl / numberLitValue

Method numberLitValue

hclsyntax/parser.go:1132–1151  ·  view source on GitHub ↗
(tok Token)

Source from the content-addressed store, hash-verified

1130}
1131
1132func (p *parser) numberLitValue(tok Token) (cty.Value, hcl.Diagnostics) {
1133 // The cty.ParseNumberVal is always the same behavior as converting a
1134 // string to a number, ensuring we always interpret decimal numbers in
1135 // the same way.
1136 numVal, err := cty.ParseNumberVal(string(tok.Bytes))
1137 if err != nil {
1138 ret := cty.UnknownVal(cty.Number)
1139 return ret, hcl.Diagnostics{
1140 {
1141 Severity: hcl.DiagError,
1142 Summary: "Invalid number literal",
1143 // FIXME: not a very good error message, but convert only
1144 // gives us "a number is required", so not much help either.
1145 Detail: "Failed to recognize the value of this number literal.",
1146 Subject: &tok.Range,
1147 },
1148 }
1149 }
1150 return numVal, nil
1151}
1152
1153// finishParsingFunctionCall parses a function call assuming that the function
1154// name was already read, and so the peeker should be pointing at the opening

Callers 3

parseTraversalMethod · 0.95
parseExpressionTermMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected