Skip to content

cmd/compile: float/int conversion differences from CL 691135 causing failures #75834

@jakebailey

Description

@jakebailey

Go version

go1.26-devel_9db7e30b

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/jabaile/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/jabaile/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build553713773=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/jabaile/work/TypeScript-go/go.mod'
GOMODCACHE='/home/jabaile/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/jabaile/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/jabaile/sdk/gotip'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/jabaile/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/jabaile/sdk/gotip/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.26-devel_9db7e30b Thu Oct 9 09:13:29 2025 -0700'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

The typescript-go repo has implementations of ECMAScript number handling; we have to do terrible things in order to implement the spec for number conversions between float64/int32/uint32. After CL 691135, our tests fail for certain edge cases.

I know the CL was intended to line up AMD64 and ARM64, but our test passed under both previously, so something is weird here.

What did you see happen?

With https://github.com/microsoft/typescript-go, do go test ./internal/jsnum:

--- FAIL: TestBitwiseNOT (0.00s)
    --- FAIL: TestBitwiseNOT/-2147483649 (0.00s)
        jsnum_test.go:123: assertion failed: -1 (got jsnum.Number) != -2147483648 (want jsnum.Number)
--- FAIL: TestToInt32 (0.00s)
    --- FAIL: TestToInt32/MinInt32-1_(-2.147483649e+09) (0.00s)
        jsnum_test.go:89: assertion failed: 0 (int32) != 2147483647 (test.want int32)
    --- FAIL: TestToInt32/-math.Pi_(-3.141592653589793) (0.00s)
        jsnum_test.go:89: assertion failed: 0 (int32) != -3 (test.want int32)
    --- FAIL: TestToInt32/-math.E_(-2.718281828459045) (0.00s)
        jsnum_test.go:89: assertion failed: 0 (int32) != -2 (test.want int32)
    --- FAIL: TestToInt32/MIN_SAFE_INTEGER+1_(-9.00719925474099e+15) (0.00s)
        jsnum_test.go:89: assertion failed: 0 (int32) != 2 (test.want int32)
    --- FAIL: TestToInt32/-2^31_-_0.5_(-2.1474836485e+09) (0.00s)
        jsnum_test.go:89: assertion failed: 0 (int32) != -2147483648 (test.want int32)
    --- FAIL: TestToInt32/MIN_SAFE_INTEGER_(-9.007199254740991e+15) (0.00s)
        jsnum_test.go:89: assertion failed: 0 (int32) != 1 (test.want int32)
    --- FAIL: TestToInt32/-8589934590_(-8.58993459e+09) (0.00s)
        jsnum_test.go:89: assertion failed: 0 (int32) != 2 (test.want int32)
FAIL
FAIL    github.com/microsoft/typescript-go/internal/jsnum       0.167s
FAIL

What did you expect to see?

Passing tests.

cc @dr2chase

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions