Skip to content

Internal/synthetic token name ElidedSemicolonAndRightBrace shows up in compile error messages #903

@trancexpress

Description

@trancexpress

Found during experiments for #859.

To reproduce, compile snippet:

public class X {
    public interface S<T> {
        T s(T t);
    }
    public void f() {
    	S<?> s = v -> v ) ;
    }
}

Observe compile error from ecj (4.27):

----------
1. ERROR in .../X.java (at line 6)
        S<?> s = v -> v ) ;
                        ^
Syntax error on token ")", ElidedSemicolonAndRightBrace expected
----------
1 problem (1 error)

Compile error from javac (OpenJDK 17):

X.java:6: error: ';' expected
        S<?> s = v -> v ) ;
                       ^
1 error

This seems to not be expected (unsurprisingly), see ProblemReporter.replaceIfSynthetic(String):

private String replaceIfSynthetic(String token) {
	/* Java 8 grammar changes use some synthetic tokens to make the grammar LALR(1). These tokens should not be exposed in messages
	   as it would make no sense to the programmer whatsoever. Replace such artificial tokens with some "suitable"  alternative. At
	   the moment, there are two synthetic tokens that need such massaging viz : "BeginLambda" and "BeginTypeArguments". There is a
	   third synthetic token "ElidedSemicolonAndRightBrace" that we don't expect to show up in messages since it is manufactured by
	   the parser automatically.
	*/

Metadata

Metadata

Labels

bugSomething isn't workingcompilerEclipse Java Compiler (ecj) related issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions