Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.8.1, 1.9-beta-1, 1.7.11
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
It seems like Groovy should be able to handle "Case 5" below,
but instead it reports a compile-time error.
//----------------------- // Case 1: OK //----------------------- bar = 0 ? "moo" : "cow" //----------------------- // Case 2: OK //----------------------- bar = 0 ? "moo" : "cow" //----------------------- // Case 3: OK //----------------------- bar = 0 ? "moo" : "cow" //----------------------- // Case 4: OK //----------------------- bar = 0 ? "moo" : "cow" //--------------------------------------------------- // Case 5: ERROR. // // Compiler says: // expecting ':', found '<newline>' //--------------------------------------------------- bar = 0 ? "moo" : "cow" //----------------------------------------------------- // Case 6: OK // // Groovy cannot figure out that this is a // valid ternary without the help of the '\' // line continuation escape. How come? // //----------------------------------------------------- bar = 0 ? "moo" \ : "cow"
Issue Links
- is duplicated by
-
GROOVY-4464
Loosen white space restrictions
-
Activity
blackdrag blackdrag
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Fix Version/s | 1.7-beta-1 [ 14014 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.7-beta-1 [ 14014 ] | |
| Fix Version/s | 1.7-beta-x [ 15538 ] |
blackdrag blackdrag
made changes -
| Assignee | Jochen Theodorou [ blackdrag ] | |
| Resolution | Won't Fix [ 2 ] | |
| Fix Version/s | 1.7-beta-x [ 15538 ] | |
| Status | Open [ 1 ] | Closed [ 6 ] |
Jon Cox
made changes -
| Resolution | Won't Fix [ 2 ] | |
| Status | Closed [ 6 ] | Reopened [ 4 ] |
blackdrag blackdrag
made changes -
| Summary | Ternary operator ?: does not handle newline beforej ":" gracefully (but it seems like it could/should) | Ternary operator ?: does not handle newline before ":" gracefully |
| Issue Type | Bug [ 1 ] | Improvement [ 4 ] |
| Assignee | Jochen Theodorou [ blackdrag ] |
Guillaume Laforge
made changes -
| Link | This issue is depended upon by GROOVY-4464 [ GROOVY-4464 ] |
Guillaume Laforge
made changes -
| Link | This issue is duplicated by GROOVY-4464 [ GROOVY-4464 ] |
Guillaume Laforge
made changes -
| Link | This issue is depended upon by GROOVY-4464 [ GROOVY-4464 ] |
Guillaume Laforge
made changes -
| Assignee | Guillaume Laforge [ guillaume ] |
Guillaume Laforge
made changes -
| Status | Reopened [ 4 ] | Resolved [ 5 ] |
| Fix Version/s | 1.7.11 [ 17244 ] | |
| Fix Version/s | 1.8.1 [ 17223 ] | |
| Fix Version/s | 1.9-beta-1 [ 17153 ] | |
| Resolution | Fixed [ 1 ] |
Paul King
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |
the general rule for Groovy is to use the operator at the end of the line or use backslash to break the line over. This applies to most operators, including for example +