nilaway icon indicating copy to clipboard operation
nilaway copied to clipboard

Add object sensitivity to struct field handling

Open sonalmahajan15 opened this issue 9 months ago • 0 comments

type S struct {
	Field *int
}

func f1() *S {
	s := &S{}
	s.Field = nil
        return s
}

func f2() {
	s := &S{Field: new(int)}
        return s
}

func test() {
        s1 := f1()
	print(*s1.Field) // report error here

        s2 := f2()
	print(*s2.Field) // safe
}


sonalmahajan15 avatar Jun 23 '25 22:06 sonalmahajan15