[External] : Re: Better error message instead of "record header expected"?

Vicente Romero vicente.romero at oracle.com
Mon Sep 19 19:12:45 UTC 2022


thanks for your proposal, the final version will probably be a bit 
shorter but this one could be a good start

Vicente

On 9/19/22 12:58, Ethan McCue wrote:
> Ideally, the error message could be something like
>
>     error[E0123]: record header expected
>      --> src/Record.java:1:20
>       |
>     1 |     public record Record {
>       |    ^ record header required here
>       |
>     help: to make a record with no components, use an empty header
>       |
>     1 | public record Record() {
>       |
>
>     For more information about this error, try `javac --explain E0123`.
>
> I'm sorry that I haven't had my life in enough of a line to make that 
> full proposal though.
>
> On Mon, Sep 19, 2022 at 10:29 AM Vicente Romero 
> <vicente.romero at oracle.com> wrote:
>
>     Hi Jaikiran,
>
>     Thanks for the report, I have filed [1] to track this issue,
>
>     Thanks,
>     Vicente
>
>     [1] https://bugs.openjdk.org/browse/JDK-8294020
>
>     On 9/19/22 09:44, Jaikiran Pai wrote:
>     > Please consider this trivial code:
>     >
>     > public record Record {
>     >
>     > }
>     >
>     > Trying to compile this results in:
>     >
>     > javac Record.java
>     >
>     > Record.java:1: error: record header expected
>     >
>     > public record Record {
>     >           ^
>     >
>     > 1 error
>     >
>     > It isn't too clear what that error message means. It took me a
>     while
>     > to realize that I had missed using the () after the record's name.
>     > Changing the source to:
>     >
>     > public record Record() {
>     >
>     > }
>     >
>     > is what the error was trying to convey. Could this error message be
>     > improved?
>     >
>     > By the way, notice that the error message was pointing to the "r"
>     > letter of the "record" keyword with the ^ sign. Is that right place
>     > for this error or should it have been after the "d" of the "Record"
>     > name, similar to what appears to be reported for constructors of
>     > classes, for example:
>     >
>     > public class Event {
>     >     public Event {
>     >
>     >     }
>     > }
>     >
>     > javac Event.java
>     >
>     > Event.java:2: error: <identifier> expected
>     >     public Event {
>     >                       ^
>     > 1 error
>     >
>     > (not sure if mail clients will preserve the spacing - that ^
>     appears
>     > between the "t" and the "{")
>     >
>     > -Jaikiran
>     >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20220919/c3680abc/attachment-0001.htm>


More information about the compiler-dev mailing list