Skip to content

Output unnamed variables #1333

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Output unnamed variables #1333

wants to merge 2 commits into from

Conversation

chongkai
Copy link

@chongkai chongkai commented Jun 26, 2025

Before this PR

Exception is thrown when there are unnamed variables in source code (issue: #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?

@palantirtech
Copy link
Member

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.

@changelog-app
Copy link

changelog-app bot commented Jun 26, 2025

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

@olsavmic
Copy link

olsavmic commented Jul 19, 2025

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 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants