这是indexloc提供的服务,不要输入任何密码
Skip to content

Unexpected map key type conversion #862

@halvfigur

Description

@halvfigur

It seems map keys that aren't strings get implicitly converted to string. For example, the following expressions fail unexpectedly

1 in { 1: 0 }

Error:
cannot use int as type string in map key (1:3)
 | 1 in {1: 0}
 | ..^
{ 1: 0 }[1]

Error:
cannot use int to get an element from map[string]interface {} (1:8)
 | {1: 0}[1]
 | .......^

This expression evaluates to true

{1: 0} | keys() | first() | type() == "string"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions