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

Formatting failure with zero-width space

Open thaidn opened this issue 6 years ago • 1 comments

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

thaidn avatar May 09 '19 07:05 thaidn

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.

cushon avatar May 18 '19 05:05 cushon