Closed potalestor closed 6 months ago
@potalestor, thanks for reporting! Currently the core NilAway does not reason too much about struct fields, especially struct initializations (e.g., creating empty structs or creating empty structs and then use a helper function to properly populate the struct fields). However, we have an extension within NilAway that reason struct fields up to depth one, making NilAway capable of handling code examples in this issue.
We have not enabled it since it increases build-time overhead to be slightly >5% (under our internal testing), and also because this capability may report more false positives. We are actively working on applying more optimizations and false positive reduction to enable and integrate, but we are not there yet.
With all that said, if you would like to try it out, you can add a <nilaway struct enable>
in the file's docstring to enable this feature for this file in particular. Or this feature is also available for experimentation with the config flag experimental-struct-init
(https://github.com/uber-go/nilaway/wiki/Configuration#experimental-struct-init).
(Closing this issue for now, but feel free to reopen it if you would like to report more problems.)