Skip to content

std.member does not handle strings correctly #656

Description

@smcgivern

Regular jsonnet defines std.member on strings in terms of std.findSubstr: https://github.com/google/jsonnet/blob/813c7412d1c7a42737724d011618d0fd7865bc69/stdlib/std.jsonnet#L236-L241

This means that if the first argument is a string, the second argument can be a string of any length.

The native version added in #638 only allows the second argument to be a single-character string. That is, with this input:

{
  'foo': std.member('foobar', 'foo'),
}

go-jsonnet 0.18.0 returns:

{
   "foo": true
}

But 0.19 and later returns:

{
   "foo": false
}

Doing std.member('foobar', 'o') will return true, however.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions