From e29db8d272eff570071d84d735fcbfc9f6fbcdd8 Mon Sep 17 00:00:00 2001 From: Stephen Dolan Date: Sat, 11 May 2013 18:10:21 +0100 Subject: [PATCH] Fix bug with path handling (used in assignments). Closes #67 --- execute.c | 5 +++-- tests/all.test | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/execute.c b/execute.c index 7deeb0a..e424ed8 100644 --- a/execute.c +++ b/execute.c @@ -180,7 +180,8 @@ jv jq_next(jq_state *jq) { } if (!param) break; jv_dump(jv_copy(param->sv.value), 0); - printf("<%d>", jv_get_refcnt(param->sv.value)); + //printf("<%d>", jv_get_refcnt(param->sv.value)); + printf("<%d>", param->sv.pathidx); } if (backtracking) printf("\t"); @@ -298,7 +299,7 @@ jv jq_next(jq_state *jq) { jv_free(path_end.value); jv path = jv_array(); for (int i=path_start.pathidx; ipathbuf[i])); + path = jv_array_append(path, jv_copy(jq->pathbuf[i])); } stack_push(jq, stackval_replace(path_start, path)); break; diff --git a/tests/all.test b/tests/all.test index 83f91da..97af7e5 100644 --- a/tests/all.test +++ b/tests/all.test @@ -574,3 +574,11 @@ unique .foo[.baz] {"foo":{"bar":4},"baz":"bar"} 4 + +.[] | .error = "no, it's OK" +[{"error":true}] +{"error": "no, it's OK"} + +[{a:1}] | .[] | .a=999 +null +{"a": 999} -- 2.40.0