From 4f47ee198a5b396edf932fa5d13afb71b6746ff0 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Fri, 25 Jan 2019 13:45:53 +0000 Subject: [PATCH] hcl/hclsyntax: Fix token range reporting for invalid characters --- hcl/hclsyntax/token.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hcl/hclsyntax/token.go b/hcl/hclsyntax/token.go index f28211d..f92a409 100644 --- a/hcl/hclsyntax/token.go +++ b/hcl/hclsyntax/token.go @@ -189,6 +189,9 @@ func checkInvalidTokens(tokens Tokens) hcl.Diagnostics { toldBadUTF8 := 0 for _, tok := range tokens { + // copy token so it's safe to point to it + tok := tok + switch tok.Type { case TokenBitwiseAnd, TokenBitwiseOr, TokenBitwiseXor, TokenBitwiseNot: if toldBitwise < 4 {