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

Unclear error messages for invisible whitespace

Open ayyess opened this issue 2 years ago • 0 comments

The following program with a zero width space after the println is executable but cannot not be formatted

public class Main {
    public static void main(String[] args) {
        System.out.println​("hello");
    }
}
% java -version
openjdk version "19.0.1" 2022-10-18
OpenJDK Runtime Environment Zulu19.30+11-CA (build 19.0.1+10)
OpenJDK 64-Bit Server VM Zulu19.30+11-CA (build 19.0.1+10, mixed mode, sharing)
% javac Main.java
% java Main
hello
% google-java-format --version
google-java-format: Version 1.17.0
% google-java-format Main.java
Main.java:3:10: error: expected token: 'println'; generated println instead

ayyess avatar Jul 31 '23 17:07 ayyess