From d5a518cc926bc84d0f16f457da87b09138e9680f Mon Sep 17 00:00:00 2001 From: Noah Treuhaft Date: Mon, 24 Aug 2026 12:08:01 -0400 Subject: [PATCH] compile/semantic: fix -csv.delim handling The semantic pass ignores the -csv.delim flag (as well as any other settings in runtime/exec.Environment.ReaderOpts). Fix this in translator.FileType by passing t.env.ReaderOpts to anyio.FileType. --- compiler/semantic/op.go | 4 +++- compiler/semantic/ztests/csv-delim.yaml | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 compiler/semantic/ztests/csv-delim.yaml diff --git a/compiler/semantic/op.go b/compiler/semantic/op.go index 002d7f8108..c9d6d43ce7 100644 --- a/compiler/semantic/op.go +++ b/compiler/semantic/op.go @@ -308,7 +308,9 @@ func (t *translator) fileType(path, format string) (super.Type, error) { if engine == nil { return t.checker.unknown, nil } - return anyio.FileType(t.ctx, t.sctx, engine, path, anyio.ReaderOpts{Format: format}, t.env.SampleSize) + opts := t.env.ReaderOpts + opts.Format = format + return anyio.FileType(t.ctx, t.sctx, engine, path, opts, t.env.SampleSize) } func (t *translator) fromFileGlob(globLoc ast.Node, pattern string, args []ast.OpArg) sem.Op { diff --git a/compiler/semantic/ztests/csv-delim.yaml b/compiler/semantic/ztests/csv-delim.yaml new file mode 100644 index 0000000000..b68e9364b5 --- /dev/null +++ b/compiler/semantic/ztests/csv-delim.yaml @@ -0,0 +1,14 @@ +# Read from a file so the semantic pass runs. +script: | + super -s -i csv -csv.delim ';' a.csv + +inputs: + - name: a.csv + data: | + a;b;c + x;y,y;z + +outputs: + - name: stdout + data: | + {a:"x",b:"y,y",c:"z"}