x/tools/go/packages: Packages.{Syntax,TypeInfo} fields are empty unless NeedTypes #63517
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
This program, which uses go/packages:
produces this output:
Why does absence of the NeedTypes mode flag cause the Syntax and TypesInfo fields, both explicitly "needed", to be missing? I think that's a bug.
This is not the first such bug like this that we've seen, and in my experience the fine-grained mode bits seem to demand a great deal of experimentation before one finds something that works. Also, they create a powerset of paint shades of Package structures of varying degrees of population, which means a function that receives a Package doesn't really know what it's going to get. In practice almost all clients want one of four things:
If memory serves a lot of the hair splitting was because of the surprising costs of some fields (e.g. package name?) in Bazel/Blaze. I'm not convinced it was worthwhile, and I wish we could un-deprecate the old compound modes and improve their documentation (perhaps with some better-named aliases). A few compound modes would cover the vast majority of practical cases, with the option of fine-grained bits for the brave and foolhardy.
The text was updated successfully, but these errors were encountered: