Skip to content

Commit

Permalink
fix missing newline in parse error and add test (#2746)
Browse files Browse the repository at this point in the history
Closes #2606
  • Loading branch information
mccanne authored May 20, 2021
1 parent ffc773b commit 7f2de51
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/parser/parser-support.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func ImproveError(src string, e error) error {
if len(lines) == 1 {
b.WriteString(fmt.Sprintf("error parsing Z at column %d:\n", colNo))
} else {
b.WriteString(fmt.Sprintf("error parsing Z at line %d, col %d:", lineNo+1, colNo))
b.WriteString(fmt.Sprintf("error parsing Z at line %d, col %d:\n", lineNo+1, colNo))
}
b.WriteString(strings.Join(lines[:lineNo+1], "\n"))
b.WriteByte('\n')
Expand Down
18 changes: 18 additions & 0 deletions compiler/ztests/badshaper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
script: zq -z -I badshaper.zed -

inputs:
- name: stdin
data: |
{"_path": "bar", "testfield": null}
- name: badshaper.zed
data: |
type foo={_path:string,testfield:"null"}
put . = shape(foo)
outputs:
- name: stderr
data: |
zq: parse error: error parsing Z at line 1, col 34:
type foo={_path:string,testfield:"null"}
=== ^ ===
put . = shape(foo)

0 comments on commit 7f2de51

Please sign in to comment.