Allow using { $__loc__ } as shorthand for { __loc__: $__loc__ }

n.b.: { $__loc__: "foo" }  is still not allowed.

$__loc__ cannot be overwritten, and it is always an object.
Using { $x: "foo" } where $x is not a string is an error, so there is
not much of a point in supporting that.
This commit is contained in:
Emanuele Torre authored and Nico Williams committed 2023-07-10 12:04:54 -05:00
1 parent 841445eea7
commit 6ca7973d49
3 files changed
+1059 -1029

No files matched your search

+6
View File
@@ -1792,3 +1792,9 @@ reduce .[] as $then (4 as $else | $else; . as $elif | . + $then * $elif)
[ foreach .[] as $try (1 as $catch | $catch - 1; . + $try; .) ]
[10,9,8,7]
[10,19,27,34]
# { $__loc__ } works
{ a, $__loc__, c }
{"a":[1,2,3],"b":"foo","c":{"hi":"hey"}}
{"a":[1,2,3],"__loc__":{"file":"<top-level>","line":1},"c":{"hi":"hey"}}