Skip to content

Commit

Permalink
hcl/parser: don't print "illegal"
Browse files Browse the repository at this point in the history
We shouldn't output any text during parsing, that's just strange!

token.ILLEGAL happens when the scanner has an error. This error is
recorded in `scerr` during parsing which is eventually returned out.
Therefore, we handle the error properly. We can simply return a backup
error here in case we don't (scanner errors are checked first).
  • Loading branch information
mitchellh committed Nov 30, 2016
1 parent 5550aab commit 6000b27
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion hcl/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,10 @@ func (p *Parser) objectKey() ([]*ast.ObjectKey, error) {
keyCount++
keys = append(keys, &ast.ObjectKey{Token: p.tok})
case token.ILLEGAL:
fmt.Println("illegal")
return keys, &PosError{
Pos: p.tok.Pos,
Err: fmt.Errorf("illegal character"),
}
default:
return keys, &PosError{
Pos: p.tok.Pos,
Expand Down

0 comments on commit 6000b27

Please sign in to comment.