Skip to content

Commit

Permalink
fix: advance past comments in go expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
knudtty committed Aug 3, 2024
1 parent 5d41a6b commit e36bcf0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.754
0.2.756
4 changes: 3 additions & 1 deletion parser/v2/goexpression/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func Expression(src string) (start, end int, err error) {
errorHandler := func(pos token.Position, msg string) {
err = fmt.Errorf("error parsing expression: %v", msg)
}
s.Init(file, []byte(src), errorHandler, 0)
s.Init(file, []byte(src), errorHandler, scanner.ScanComments)

// Read chains of identifiers and constants up until RBRACE, e.g.:
// true
Expand Down Expand Up @@ -185,6 +185,8 @@ loop:
continue
case token.ILLEGAL:
return 0, 0, fmt.Errorf("illegal token: %v", lit)
case token.COMMENT:
end = int(pos) + len(lit) - 1
default:
end = int(pos) + len(tok.String()) - 1
}
Expand Down

0 comments on commit e36bcf0

Please sign in to comment.