Skip to content

Commit

Permalink
parser: fix panicing for # style comments
Browse files Browse the repository at this point in the history
HCL supports # style comments, which are 1 size len. We assumed that
it's always // or /* , which are two size length
  • Loading branch information
fatih committed Oct 31, 2015
1 parent 9b50830 commit 07cb426
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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' {
Expand Down

0 comments on commit 07cb426

Please sign in to comment.