databricks / sjsonnet

Apache License 2.0
267 stars 55 forks source link

%d in format strings should only accept numbers #139

Closed nicklan closed 4 weeks ago

nicklan commented 3 years ago

Example file:

"%(thing)d" % {
  thing: "NOT A NUMBER"
}

go-jsonnet:

$ jsonnet num.jsonnet
RUNTIME ERROR: Format required number at thing, got string
    <std>:(588:11)-(589:47) function <format_code>
    <std>:761:15-50 thunk <s> from <function <format_codes_obj>>
    <std>:766:24-25 thunk from <thunk <s_padded> from <function <format_codes_obj>>>
    <std>:480:30-33 thunk from <thunk from <function <pad_left>>>
    <std>:480:19-34 thunk from <function <pad_left>>
    <std>:476:11-12 thunk from <function <padding>>
    <std>:472:12-13 function <aux>
    <std>:476:7-17  function <padding>
    <std>:480:7-38  function <pad_left>
    <std>:766:15-35 thunk <s_padded> from <function <format_codes_obj>>
    <std>:767:51-59 thunk from <function <format_codes_obj>>
    <std>:767:11-60 function <format_codes_obj>
    <std>:772:7-43  function <anonymous>
    <std>:237:7-23  function <anonymous>
    /tmp/num.jsonnet:(1:1)-(3:2)    
    During evaluation

sjsonnet:

$ sjsonnet num.jsonnet
"NOT A NUMBER"