You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This may be caused by go1.21 is removing the function due the if false condition being constant, though it should not be removed because it is registered some where else using IR.
package mock_closuer
import"testing"// see https://github.com/xhd2015/xgo/issues/13funcTestClosuerWithIfFalse(t*testing.T) {
// assert this functionvaraintiffalse {
func() {
a=10
}()
}
ifa!=0 {
t.Fatalf("expect a to be 0, actual: %d", a)
}
}
funcTestClosuerWithIfTrue(t*testing.T) {
varaintiftrue {
func() {
a=10
}()
}
ifa!=10 {
t.Fatalf("expect a to be 10, actual: %d", a)
}
}
xgo version: v1.0.10
go version: go 1.21
code
error:
$ xgo test ./demo sub.TestClosuerWithIf.func1·f: relocation target sub.TestClosuerWithIf.func1 not defined FAIL demo [build failed]
However, without the
if condition
, everything works fine.With go1.22, the above code works fine.
The text was updated successfully, but these errors were encountered: