From 7f2de518631fe403f733ce3f210a971c3ec35341 Mon Sep 17 00:00:00 2001 From: Steve McCanne Date: Thu, 20 May 2021 14:47:00 -0700 Subject: [PATCH] fix missing newline in parse error and add test (#2746) Closes #2606 --- compiler/parser/parser-support.go | 2 +- compiler/ztests/badshaper.yaml | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 compiler/ztests/badshaper.yaml diff --git a/compiler/parser/parser-support.go b/compiler/parser/parser-support.go index 8b0166398a..69decf7f75 100644 --- a/compiler/parser/parser-support.go +++ b/compiler/parser/parser-support.go @@ -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') diff --git a/compiler/ztests/badshaper.yaml b/compiler/ztests/badshaper.yaml new file mode 100644 index 0000000000..12827626a2 --- /dev/null +++ b/compiler/ztests/badshaper.yaml @@ -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)