mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
vendor: go get github.com/hashicorp/hcl2@master
This includes a new specialized error message for when a fractional number is used to index a sequence.
This commit is contained in:
parent
bb118c37a2
commit
6a156f67ce
2
go.mod
2
go.mod
@ -60,7 +60,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-20190402200843-8b450a7d58f9
|
||||
github.com/hashicorp/hcl2 v0.0.0-20190416162332-2c5a4b7d729a
|
||||
github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590
|
||||
github.com/hashicorp/logutils v1.0.0
|
||||
github.com/hashicorp/memberlist v0.1.0 // indirect
|
||||
|
4
go.sum
4
go.sum
@ -202,8 +202,8 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
||||
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f h1:UdxlrJz4JOnY8W+DbLISwf2B8WXEolNRA8BGCwI9jws=
|
||||
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
|
||||
github.com/hashicorp/hcl2 v0.0.0-20181208003705-670926858200/go.mod h1:ShfpTh661oAaxo7VcNxg0zcZW6jvMa7Moy2oFx7e5dE=
|
||||
github.com/hashicorp/hcl2 v0.0.0-20190402200843-8b450a7d58f9 h1:zCITwiA0cog6aYr/a/McDHKtgsEpYxXvTIgugv5iu8o=
|
||||
github.com/hashicorp/hcl2 v0.0.0-20190402200843-8b450a7d58f9/go.mod h1:HtEzazM5AZ9fviNEof8QZB4T1Vz9UhHrGhnMPzl//Ek=
|
||||
github.com/hashicorp/hcl2 v0.0.0-20190416162332-2c5a4b7d729a h1:doKt9ZBCYgYQrGK6CqJsEB+8xqm3WoFyKu4TPZlyymg=
|
||||
github.com/hashicorp/hcl2 v0.0.0-20190416162332-2c5a4b7d729a/go.mod h1:HtEzazM5AZ9fviNEof8QZB4T1Vz9UhHrGhnMPzl//Ek=
|
||||
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=
|
||||
|
22
vendor/github.com/hashicorp/hcl2/hcl/ops.go
generated
vendored
22
vendor/github.com/hashicorp/hcl2/hcl/ops.go
generated
vendored
@ -2,6 +2,7 @@ package hcl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
"github.com/zclconf/go-cty/cty/convert"
|
||||
@ -84,6 +85,27 @@ func Index(collection, key cty.Value, srcRange *Range) (cty.Value, Diagnostics)
|
||||
}
|
||||
}
|
||||
if has.False() {
|
||||
// We have a more specialized error message for the situation of
|
||||
// using a fractional number to index into a sequence, because
|
||||
// that will tend to happen if the user is trying to use division
|
||||
// to calculate an index and not realizing that HCL does float
|
||||
// division rather than integer division.
|
||||
if (ty.IsListType() || ty.IsTupleType()) && key.Type().Equals(cty.Number) {
|
||||
if key.IsKnown() && !key.IsNull() {
|
||||
bf := key.AsBigFloat()
|
||||
if _, acc := bf.Int(nil); acc != big.Exact {
|
||||
return cty.DynamicVal, Diagnostics{
|
||||
{
|
||||
Severity: DiagError,
|
||||
Summary: "Invalid index",
|
||||
Detail: fmt.Sprintf("The given key does not identify an element in this collection value: indexing a sequence requires a whole number, but the given index (%g) has a fractional part.", bf),
|
||||
Subject: srcRange,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cty.DynamicVal, Diagnostics{
|
||||
{
|
||||
Severity: DiagError,
|
||||
|
3
vendor/github.com/hashicorp/hcl2/hcl/pos.go
generated
vendored
3
vendor/github.com/hashicorp/hcl2/hcl/pos.go
generated
vendored
@ -31,6 +31,9 @@ type Pos struct {
|
||||
Byte int
|
||||
}
|
||||
|
||||
// InitialPos is a suitable position to use to mark the start of a file.
|
||||
var InitialPos = Pos{Byte: 0, Line: 1, Column: 1}
|
||||
|
||||
// Range represents a span of characters between two positions in a source
|
||||
// file.
|
||||
//
|
||||
|
18
vendor/github.com/hashicorp/hcl2/hcl/pos_scanner.go
generated
vendored
18
vendor/github.com/hashicorp/hcl2/hcl/pos_scanner.go
generated
vendored
@ -29,8 +29,8 @@ type RangeScanner struct {
|
||||
err error // error from last scan, if any
|
||||
}
|
||||
|
||||
// Create a new RangeScanner for the given buffer, producing ranges for the
|
||||
// given filename.
|
||||
// NewRangeScanner creates a new RangeScanner for the given buffer, producing
|
||||
// ranges for the given filename.
|
||||
//
|
||||
// Since ranges have grapheme-cluster granularity rather than byte granularity,
|
||||
// the scanner will produce incorrect results if the given SplitFunc creates
|
||||
@ -39,15 +39,19 @@ type RangeScanner struct {
|
||||
// around individual UTF-8 sequences, which will split any multi-sequence
|
||||
// grapheme clusters.
|
||||
func NewRangeScanner(b []byte, filename string, cb bufio.SplitFunc) *RangeScanner {
|
||||
return NewRangeScannerFragment(b, filename, InitialPos, cb)
|
||||
}
|
||||
|
||||
// NewRangeScannerFragment is like NewRangeScanner but the ranges it produces
|
||||
// will be offset by the given starting position, which is appropriate for
|
||||
// sub-slices of a file, whereas NewRangeScanner assumes it is scanning an
|
||||
// entire file.
|
||||
func NewRangeScannerFragment(b []byte, filename string, start Pos, cb bufio.SplitFunc) *RangeScanner {
|
||||
return &RangeScanner{
|
||||
filename: filename,
|
||||
b: b,
|
||||
cb: cb,
|
||||
pos: Pos{
|
||||
Byte: 0,
|
||||
Line: 1,
|
||||
Column: 1,
|
||||
},
|
||||
pos: start,
|
||||
}
|
||||
}
|
||||
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -307,7 +307,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-20190402200843-8b450a7d58f9
|
||||
# github.com/hashicorp/hcl2 v0.0.0-20190416162332-2c5a4b7d729a
|
||||
github.com/hashicorp/hcl2/hcl
|
||||
github.com/hashicorp/hcl2/hcl/hclsyntax
|
||||
github.com/hashicorp/hcl2/hcldec
|
||||
|
Loading…
Reference in New Issue
Block a user