...the parser seems to not be detecting that for keyword as a for expression introducer and instead treating it as a map key expression.
It seems like the peek-ahead for that keyword isn't working correctly with the intervening newline, even though we turn off newline-sensitive tokenization before peeking it:
Perhaps somehow the newline token is ending up in the peek slot before PushIncludeNewlines(false) takes effect, and so it's still there when we subsequently call Peek. Will need to dig into the parser code some more to see what's going on here.
Given input like this:
...the parser seems to not be detecting that
for
keyword as a for expression introducer and instead treating it as a map key expression.It seems like the peek-ahead for that keyword isn't working correctly with the intervening newline, even though we turn off newline-sensitive tokenization before peeking it:
https://github.com/hashicorp/hcl2/blob/3e4b7e0eb20ecc20e70dbd458f7a54daf0032830/hcl/hclsyntax/parser.go#L1023-L1028
Perhaps somehow the newline token is ending up in the peek slot before
PushIncludeNewlines(false)
takes effect, and so it's still there when we subsequently callPeek
. Will need to dig into the parser code some more to see what's going on here.