Skip to content

Commit 5a9d395

Browse files
authored
Revert "Add ability to refer to subfields of objects via dot notation in string formatting (#1011)" (#1099)
This reverts commit 1cefde7.
1 parent 1cefde7 commit 5a9d395

4 files changed

+4
-42
lines changed

stdlib/std.jsonnet

+4-17
Original file line numberDiff line numberDiff line change
@@ -770,24 +770,11 @@ limitations under the License.
770770
error 'Cannot use * precision with object.'
771771
else
772772
code.prec;
773-
local get_nested_val(obj, f, start=0, end=0) =
774-
if !std.isObject(obj) then
775-
error 'Subfield ' + f[:start] + ' didn\'t yield an object.'
776-
else if end >= std.length(f) then
777-
if std.objectHasAll(obj, f[start:]) then
778-
obj[f[start:]]
779-
else
780-
error 'No such field: ' + f
781-
else if f[end] == "." then
782-
local key = f[start:end];
783-
if std.objectHasAll(obj, key) then
784-
get_nested_val(obj[key], f, end+1, end+1) tailstrict
785-
else
786-
error 'No such partial field: ' + f[:end]
773+
local val =
774+
if std.objectHasAll(obj, f) then
775+
obj[f]
787776
else
788-
get_nested_val(obj, f, start, end+1) tailstrict
789-
;
790-
local val = get_nested_val(obj, f);
777+
error 'No such field: ' + f;
791778
local s =
792779
if code.ctype == '%' then
793780
'%'

test_suite/error.format.invalid_object_subfield.jsonnet

-2
This file was deleted.

test_suite/error.format.invalid_object_subfield.jsonnet.golden

-22
This file was deleted.

test_suite/format.jsonnet

-1
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,5 @@ local text = |||
312312

313313
std.assertEqual(std.length(text), 1244) &&
314314

315-
std.assertEqual(std.format('%(a.b.c.d)s %(b.c)s', {a:{b:{c:{d:'hello'}}}, b:{c:'goodbye'}}), 'hello goodbye') &&
316315

317316
true

0 commit comments

Comments
 (0)