[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

Christopher Di Bella via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 27 09:37:29 PDT 2023


cjdb added inline comments.


================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6589
+def err_using_placeholder_variable : Error<
+  "referring to placeholder '_' is not allowed">;
+def note_reference_placeholder : Note<
----------------
aaron.ballman wrote:
> I don't think this helps the user understand what's wrong with their code, especially given the somewhat odd language rules around the feature. How about: `ambiguous reference to multiply-defined placeholder '_'` or something along those lines? Then the note can show the previous declarations of the placeholders that are in scope? e.g.,
> ```
> void g() {
> int _; // note: placeholder declared here
> _ = 0;
> int _; // note: placeholder declared here
> _ = 0; // error: `ambiguous reference to multiply-defined placeholder '_'`
> }
> ```
> CC @cjdb 
Agreed. I'd suggest a rewording though: I took "multiply" to mean the maths term until completing the sentence, rather than its alternative meaning of "multiple instances" (which is more or less the same meaning, but "multiply" maps to the `x * y` operation for me).

Perhaps `ambiguous reference to placeholder '_', which has multiple definitions`? Not sold on that being the best wording, but it does avoid the hardcoded-word-at-8yo problem :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153536/new/

https://reviews.llvm.org/D153536



More information about the cfe-commits mailing list