google / cel-go

Fast, portable, non-Turing complete expression evaluation with gradual typing (Go)
https://cel.dev
Apache License 2.0
2.19k stars 218 forks source link

Test fails to compile on 32-bit architectures #971

Open siretart opened 2 months ago

siretart commented 2 months ago

Hi, I'm packaging this library for use of other packages in Debian.

I noticed that in Debian, the tests fails to build on 32bit architectures, e.g.:

In all cases, the relevant part of the build log looks like this:

132s # github.com/google/cel-go/common/types [github.com/google/cel-go/common/types.test]
132s src/github.com/google/cel-go/common/types/int_test.go:41:17: cannot use math.MaxInt64 (untyped int constant 9223372036854775807) as int value in assignment (overflows)
132s src/github.com/google/cel-go/common/types/int_test.go:44:17: cannot use math.MinInt64 (untyped int constant -9223372036854775808) as int value in assignment (overflows)
132s src/github.com/google/cel-go/common/types/int_test.go:47:17: cannot use math.MaxInt64 - 1 (untyped int constant 9223372036854775806) as int value in assignment (overflows)
132s src/github.com/google/cel-go/common/types/int_test.go:48:63: cannot use math.MaxInt64 (untyped int constant 9223372036854775807) as int value in argument to t.Errorf (overflows)
132s src/github.com/google/cel-go/common/types/int_test.go:50:17: cannot use math.MinInt64 + 1 (untyped int constant -9223372036854775807) as int value in assignment (overflows)
132s src/github.com/google/cel-go/common/types/int_test.go:51:63: cannot use math.MaxInt64 (untyped int constant 9223372036854775807) as int value in argument to t.Errorf (overflows)
132s src/github.com/google/cel-go/common/types/int_test.go:355:17: cannot use math.MinInt64 (untyped int constant -9223372036854775808) as int value in assignment (overflows)
132s src/github.com/google/cel-go/common/types/int_test.go:420:17: cannot use math.MinInt64 (untyped int constant -9223372036854775808) as int value in assignment (overflows)
132s src/github.com/google/cel-go/common/types/int_test.go:432:17: cannot use math.MaxInt64 / 2 (untyped int constant 4611686018427387903) as int value in assignment (overflows)
132s src/github.com/google/cel-go/common/types/int_test.go:435:17: cannot use math.MinInt64 / 2 (untyped int constant -4611686018427387904) as int value in assignment (overflows)
132s src/github.com/google/cel-go/common/types/int_test.go:435:17: too many errors

I suspect the issue is here: https://github.com/google/cel-go/blob/b27008a343bcb5805b63816e41954b3100a05be5/common/types/int_test.go#L35-L54

That test code seems to be written with the assumption to run on 64bit architectures only. I'm going to disable this test in Debian for now, but please let me know if you can think of a better way to address this issue.

TristonianJones commented 2 months ago

My apologies @siretart, I thought I had replied to this thread, but it's possible there are other issues in common/types/int.go and common/types/overflow.go. I'm happy to update reference to these constants where they occur. If I read this right it means type converting the constants, e.g. int64(math.MaxInt64), does that sound right to you?