google / google-java-format

Reformats Java source code to comply with Google Java Style.
Other
5.61k stars 854 forks source link

Formatting failure with zero-width space #372

Open thaidn opened 5 years ago

thaidn commented 5 years ago

Test case:

package test;

import com.google.common.util.concurrent.AtomicLongMap;

class Foo {
  AtomicLongMap<String> a = AtomicLongMap.create().getAndIncrement​("foo");
}

Error:

src/Test.java:6:30: error: expected token: 'getAndIncrement​'; generated getAndIncrement instead

Version:

google-java-format --version google-java-format: Version 1.6

cushon commented 5 years ago

If nothing else the formatter should be reported a better diagnostic here, but there's a zero-width space in that example getAndIncrement<200b>("foo"), which is disallowed by the style guide.

Removing that character should allow the file to be formatted successfully.