-
Notifications
You must be signed in to change notification settings - Fork 1.7k
comment_references
doesn't recognize named fields in records (false positive?)
#59237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
comment_references
doesn't recognize named fields in recordscomment_references
doesn't recognize named fields in records (false positive?)
There are a couple of reasons why I'm thinking that we don't want to support using named record fields in doc comment references. The first is because record are structurally typed, so the reference can easily be ambiguous. See #53024 (comment) for an example of what I'm talking about. The second is because record fields are somewhat analogous to fields in objects, and we don't support references to object fields in doc comment references. For example, I wouldn't expect that we'd want to support writing /// I can reference [c], but not [f].
void f(C c) {}
class C {
int f;
} and have the reference to I can certainly see wanting to document what the record fields represent, or what values they should have, but I don't think we want to try to support navigation / linking (in |
An interesting case that was just brought to my attention:
where it does seem reasonable to be able to document the fields of the type in the documentation of the |
That case is also in the original issue text. I agree with the assessments in each of your comments. |
What If In any case:
|
(Given that the same team is currently responsible for both tools, I'm fine having the discussion remain here.) |
Extending the semantics of references to allow references to members of objects and records is interesting. I wouldn't want us to generalize to include arbitrary expressions as references, and I'd be hesitant to allow multiple member accesses (such as |
I've opened #55584 for the issue of whether the analyzer should be enhanced to recognize such inner identifiers as referable. This issue is closed though; the |
Describe the issue
The
comment_references
lint does not recognize referenced named fields in records present in function parameter types or return signatures.It is unclear whether the current behavior is intentional, as functions are not directly responsible for record fields declared in their type signature—which becomes more evident when using typedefs. This prompts the question: how should documentation be handled in this case?
To Reproduce
But what should happen here? Where do we expect to document these fields?
Expected behavior
In the reproducible example, both
[key]
and[value]
references should be considered visible in scope—and thus not marked by the lint—as they are present in the function signature.The text was updated successfully, but these errors were encountered: