runtime: type-assertion on Safari/WASM sometimes generates "types from different scopes" #46895
Labels
arch-wasm
WebAssembly issues
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
It's dificult to reproduce the issue, I tried to create many structs and all of them works. In my program I use the following construction:
The
sp.Request.Result()
returns ainterface{}
which contains the decoded body from http request. For every response, I use the type-assertion. So, for Login page it may have something like*common.LoginResponse
and on SignUp it will use*common.SignUpResponse
, for instance.On all platforms, the code works, except on Safari/WebAssembly. The code works on many cases (say
*common.OrderCreateResponse
works, but*common.SignUpResponse
doesn't). That is why is so difficult to create a test or to provide a code to reproduce the issue.What did you expect to see?
The same behavior of all other OSes (including the WebAssembly on Chrome/Windows). On all other OSes (Windows, Linux, Android) and also on WebAssembly runing on Windows and Android: the
ok
from the type-assertion istrue
.What did you see instead?
The
ok
on type-assertion returnsfalse
on Safari/WebAssembly. However, theresp
of the same type-assertion is a non-nil value, which contains the data/struct correctly.More tests and weird results:
ok
: (fail)It works on all OSes, except on Safari, which gives:
ok
: (works)It works everywhere, including Safari. The
resp
is a non-nil! Notice that I'm usingresp, _ :=
instead ofresp :=
.It works everywhere, including Safari.
reflect
before the type-assertion (works):For some random reason, that works on Safari! When I insert the prints, the
resp.(*common.OrderCreateResponse)
returnsok=true
, for some unknown reason.The text was updated successfully, but these errors were encountered: