Skip to content

Change in behavior in 1.15 with in and float64 #426

Closed
@zachaller

Description

@zachaller

In argo rollouts we had our tests starting to fail on 1.15 it seems that we needed to be explicit in converting to floats which we did not have to before here are two examples.

1.14.0: https://goplay.tools/snippet/gaA2hxV9auw

        env := map[string]interface{}{
		"res": []float64{10, 11},
	}
	code := "10 in res"

	program, err := expr.Compile(code, expr.Env(env))
	fmt.Println(err)

        //output: true

1.15.0: https://goplay.tools/snippet/rZsOUyfRRop

        env := map[string]interface{}{
		"res": []float64{10, 11},
	}
	code := "10 in res"

	program, err := expr.Compile(code, expr.Env(env))
	fmt.Println(err)

        //output: cannot use int as type float64 in array

Working in 1.15.0 with explicit casting: https://goplay.tools/snippet/XBqyWpRfj6I

        env := map[string]interface{}{
		"res": []float64{10, 11},
	}
	code := "float(10) in res"

	program, err := expr.Compile(code, expr.Env(env))
	fmt.Println(err)

        //output: true

Is this expected behavior?

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