parser: fix panicing for # style comments
HCL supports # style comments, which are 1 size len. We assumed that it's always // or /* , which are two size length
This commit is contained in:
parent
9b5083066a
commit
07cb426729
@ -78,7 +78,7 @@ func (p *Parser) consumeComment() (comment *ast.Comment, endline int) {
|
||||
endline = p.tok.Pos.Line
|
||||
|
||||
// count the endline if it's multiline comment, ie starting with /*
|
||||
if p.tok.Text[1] == '*' {
|
||||
if len(p.tok.Text) > 1 && p.tok.Text[1] == '*' {
|
||||
// don't use range here - no need to decode Unicode code points
|
||||
for i := 0; i < len(p.tok.Text); i++ {
|
||||
if p.tok.Text[i] == '\n' {
|
||||
|
Loading…
x
Reference in New Issue
Block a user