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
When dereferencing a nil pointer, the behavior is inconsistent with expectations. Specifically, dereferencing a nil pointer for a field does not cause a runtime error and instead returns the zero value for a field.
Steps to Reproduce:
Define a struct type with a field.
Create a nil pointer to the struct.
Attempt to access a field via the nil pointer.
Code example:
type MyStruct: struct{
Value: int
}
func main {
myStruct: *MyStruct // nil pointer
println(myStruct.Value) // print 0
}
Expected Behavior:
The program should produce a runtime error indicating an invalid memory access, similar to the behavior in Go:
This behavior could lead to silent errors in programs, making debugging challenging. Aligning this behavior with Go would enhance developer experience and reliability.
The text was updated successfully, but these errors were encountered:
Description:
When dereferencing a
nil
pointer, the behavior is inconsistent with expectations. Specifically, dereferencing anil
pointer for a field does not cause a runtime error and instead returns the zero value for a field.Steps to Reproduce:
nil
pointer to the struct.nil
pointer.Code example:
Expected Behavior:
The program should produce a runtime error indicating an invalid memory access, similar to the behavior in Go:
Environment:
Additional Notes:
This behavior could lead to silent errors in programs, making debugging challenging. Aligning this behavior with Go would enhance developer experience and reliability.
The text was updated successfully, but these errors were encountered: