Typecasting nil results in non-nil
Author: seanburke-wfCreated Jul 17, 2018Updated Apr 26, 2026
LabelsbugNeedsFixNeedsHelp
If a variable has value nil and is typecast, the result will have a non-nil value which appears to be an invalid pointer. This differs from the behavior of Go.
The following illustrate the difference in behaviors between Go and compiled gopherjs: https://play.golang.org/p/_feur6S2EjC https://gopherjs.github.io/playground/#/y785Hlp5q0
Additionally, the non-nil value appears to be an invalid reference: https://play.golang.org/p/ugzWXe4x2HE https://gopherjs.github.io/playground/#/HkVf0Bqs1m
Source: gopherjs/gopherjs