Skip to content
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

ElidedSemicolonAndRightBrace in compile error message #903

Open
trancexpress opened this issue Mar 23, 2023 · 5 comments
Open

ElidedSemicolonAndRightBrace in compile error message #903

trancexpress opened this issue Mar 23, 2023 · 5 comments
Labels
bug Something isn't working compiler Eclipse Java Compiler (ecj) related issues

Comments

@trancexpress
Copy link
Contributor

trancexpress commented Mar 23, 2023

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.
	*/
@trancexpress trancexpress added bug Something isn't working compiler Eclipse Java Compiler (ecj) related issues labels Mar 23, 2023
@mpalat mpalat added the good first issue Good for newcomers label Apr 7, 2023
@mpalat mpalat self-assigned this Apr 7, 2023
@mpalat
Copy link
Contributor

mpalat commented Apr 7, 2023

@trancexpress Am planning to work with a couple of newcomers (already identified) for this - hence self-assigned for now.

@trancexpress
Copy link
Contributor Author

@trancexpress Am planning to work with a couple of newcomers (already identified) for this - hence self-assigned for now.

Sounds great! If possible, can you look into #859, #367, and #125 as well? They seems to be very related to this bug. Possibly all can be fixed with the same change. See also the comment from Stephan here: #125 (comment)

There seems to be some complicated workaround for lambdas, that is maybe not necessary anymore. To my understanding, this workaround is the cause for the unexpected error message here.

@srikanth-sankaran
Copy link
Contributor

I don't think this qualifies as a good-first-issue. Nothing to do with DiagnoseParse qualifies as a "good" issue or a "first" issue let alone a "good first" issue (guffaw)

@iloveeclipse iloveeclipse removed the good first issue Good for newcomers label May 11, 2023
@srikanth-sankaran
Copy link
Contributor

You may want to look at the decidedly low-tech solution adopted for #367

@mpalat mpalat removed their assignment May 14, 2024
@mpalat
Copy link
Contributor

mpalat commented May 14, 2024

I don't think this qualifies as a good-first-issue. Nothing to do with DiagnoseParse qualifies as a "good" issue or a "first" issue let alone a "good first" issue (guffaw)

point taken - removed the assignment for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler Eclipse Java Compiler (ecj) related issues
Projects
None yet
Development

No branches or pull requests

4 participants