Skip to content

Array comparison is no longer compatible with lower versions #371

@fujiwaram

Description

@fujiwaram

Array comparison behavior is changed from v1.10.0.

e.g.

func main() {
	env := map[string]interface{}{
		"names": []string{"A", "B"},
	}
	code := `["A", "B"] == names`

	program, _ := expr.Compile(code, expr.Env(env))
	output, _ := expr.Run(program, env)
	fmt.Println(output)
}
  • v1.9.0 or before
    result: true
    []string{“A”, "B"} == []string{"A", "B"}
  • v1.10.0 or after
    result: false
    // internal type is []interface{}, so type mismatch
    []interface{}{“A”, "B"} == []string{"A", "B"}

v1.9.0: https://goplay.tools/snippet/tayU9IxLSFz
v1.10.0: https://goplay.tools/snippet/Ezau-zbCscu

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions