zed icon indicating copy to clipboard operation
zed copied to clipboard

map index selectors on this returns missing

Open mattnibs opened this issue 3 years ago • 1 comments

If I do a map index selector on this I get a "missing" error:

$ echo '|{"one":1}|' | go run ./cmd/zq 'yield this["one"]' -
error("missing")

If the index selector is on a map inside an array, however this works:

$ echo '{a:|{"one":1}|}' | go run ./cmd/zq 'yield a["one"]' -
1

There appears to be something funny going on in the semantic pass. For yield this["one"] I get (note the lack of '[' operator):

{
            "exprs": [
                {
                    "kind": "This",
                    "path": [
                        "hi"
                    ]
                }
            ],
            "kind": "Yield"
        }

mattnibs avatar Feb 15 '22 16:02 mattnibs

Since this one has been hanging out for a while, I just did a quick check and confirmed that it's still with us in current Zed.

$ zq -version
Version: v1.1.0-58-gd97c452a

$ echo '|{"one":1}|' | zq 'yield this["one"]' -
error("missing")

$ echo '{a:|{"one":1}|}' | zq 'yield a["one"]' -
1

philrz avatar Jul 12 '22 00:07 philrz

#4132 fixed this. The command in the previous comment now works as expected.

$ zq -version
Version: v1.2.0-85-ge9624c3b

$ echo '|{"one":1}|' | go run ./cmd/zq 'yield this["one"]' -
1

nwt avatar Oct 12 '22 21:10 nwt