Bug 545173 - [12] Improve error message : Syntax error on token "break", invalid Expression
Summary: [12] Improve error message : Syntax error on token "break", invalid Expression
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.11   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug bulk move
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-07 08:14 EST by Noopur Gupta CLA
Modified: 2023-08-19 14:48 EDT (History)
3 users (show)

See Also:


Attachments
Screenshot (15.20 KB, image/png)
2019-03-07 08:14 EST, Noopur Gupta CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Noopur Gupta CLA 2019-03-07 08:14:20 EST
Created attachment 277797 [details]
Screenshot

See attached screenshot. "break;" is a statement and not expression.

Javac gives a nice explanatory error:
unexpected statement in case, expected is an expression, a block or a throw statement
Comment 1 Manoj N Palat CLA 2019-03-07 10:12:58 EST
(In reply to Noopur Gupta from comment #0)

> See attached screenshot. "break;" is a statement and not expression.

A reduced test case:
public class X {
	public static void foo(int i) {
		switch (i) {
		default -> break;
		}     
	}
}

Gives the error for break (without semicolon):
Syntax error on token "break", invalid Expression

Essentially, some expressions are allowed (eg MessageSend). 

Could be improved, may be later - moving out of the blocker for 12.

[Dev Note: This error is thrown in the automated parsing stage]
Comment 2 Stephan Herrmann CLA 2019-03-07 11:07:40 EST
(In reply to Manoj Palat from comment #1)
> [Dev Note: This error is thrown in the automated parsing stage]

Might require an explicit rule in the grammar modeling the wrong structure, so that its consume method can raise a dedicated error.
Comment 3 Manoj N Palat CLA 2019-08-27 02:07:39 EDT
Bulk move out of 4.13
Comment 4 Eclipse Genie CLA 2021-08-22 13:55:29 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 5 Eclipse Genie CLA 2023-08-19 14:48:06 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.