palantir-java-format icon indicating copy to clipboard operation
palantir-java-format copied to clipboard

Output unnamed variables

Open chongkai opened this issue 5 months ago β€’ 4 comments

Before this PR

Exception is thrown when there are unnamed variables in source code (issue: https://github.com/palantir/palantir-java-format/issues/1236).

The error is like, "com.palantir.javaformat.java.FormatterException: 217:106: error: expected token: '_'; generated instead".

The cases we have seen include:

  • unnamed var in try-with blocks, try (var _ = abc) {}
  • unnamed argument in lambda (a, _) -> {}

After this PR

The source code can be formatted properly when containing unnamed variables.

Possible downsides?

chongkai avatar Jun 26 '25 02:06 chongkai

Thanks for your interest in palantir/palantir-java-format, @chongkai! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

palantirtech avatar Jun 26 '25 02:06 palantirtech

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • [ ] Feature (Adding new functionality)
  • [ ] Improvement (Improving existing functionality)
  • [ ] Fix (Fixing an issue with existing functionality)
  • [ ] Break (Creating a new major version by breaking public APIs)
  • [ ] Deprecation (Removing functionality in a non-breaking way)
  • [ ] Migration (Automatically moving data/functionality to a new system)

Description Output unnamed variables

Check the box to generate changelog(s)

  • [ ] Generate changelog entry

changelog-app[bot] avatar Jun 26 '25 02:06 changelog-app[bot]

Hello, just wanted to check in β€” I’d really appreciate if we could move forward with this fix as it’s something I also need πŸ™ Thanks a ton in advance! πŸ’ͺ✨

I see tests are missing, that could prolong the code-review process πŸ€”

olsavmic avatar Jul 19 '25 12:07 olsavmic

looks like I have missed the opportunity to add the change log entry when asked by the bot. How can I add one manually now?

PS, has anyone reviewed this PR?

chongkai avatar Aug 15 '25 09:08 chongkai