Details
-
Type:
New Feature
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: X10 2.0.4, X10 2.2
-
Fix Version/s: X10 2.4
-
Component/s: X10 Compiler: Front-end, X10 Compiler: Front-end Parser
-
Labels:None
-
Environment:all?
-
Testcase included:yes
-
Number of attachments :
Description
Expression statements (assignments and method calls) cannot currently be annotated directly. Thus,
@NoInline Console.OUT.println("Hello World");
won't parse.
@Inline {Console.OUT.println("Hello World");}
will, but the annotation is on the Block, not the Expr!
The error message(s) were not particularly helpful:
C:\Users\alpern\workspace\Bug\src\XTENLANG1559.x10:3: Syntax error: Token(s) inserted to complete scope: "}"
@NoInline Console.out.println("Hello World");
^
C:\Users\alpern\workspace\Bug\src\XTENLANG1559.x10:1: Syntax error: Misplaced constructs(s): "ERROR_TOKEN"
public class XTENLANG1559 {
-------------------------
C:\Users\alpern\workspace\Bug\src\XTENLANG1559.x10:2: Syntax error: Token "class" expected instead of this input
public static def main(args: Rail[String]!): Void {
-
C:\Users\alpern\workspace\Bug\src\XTENLANG1559.x10:2: Syntax error: Token "extends" expected instead of this input
public static def main(args: Rail[String]!): Void {
^
C:\Users\alpern\workspace\Bug\src\XTENLANG1559.x10:3: Syntax error: Token(s) inserted to complete scope: ")"
@NoInline Console.out.println("Hello World");
^-------------------------------^
C:\Users\alpern\workspace\Bug\src\XTENLANG1559.x10:2-3: Syntax error: Token(s) inserted to complete scope: "}"
public static def main(args: Rail[String]!): Void {
^
@NoInline Console.out.println("Hello World");
-------------------------------------------^
C:\Users\alpern\workspace\Bug\src\XTENLANG1559.x10:3-5: Syntax error: Unexpected input ignored: ";"
@NoInline Console.out.println("Hello World");
^
...
}
-^
XTENLANG1559.x10: After goal Parser: We have unknown numbers! parentPos=XTENLANG1559.x10 nPos=XTENLANG1559.x10 parent=<<<< C:\Users\alpern\workspace\Bug\src\XTENLANG1559.x10 >>>> n=public class XTENLANG1559 { ... }
8 errors.
Issue Links
- is related to
-
XTENLANG-1938
Expressions should be allowed as statements (ie allow expr; )
-
The fact that the obvious thing does not parse is a parser issue, and will be fixed.
However, the language design states that the annotation will apply to the statement (i.e., Eval), and not to the expression (in this case a Call).
There is currently no spec for annotating the expression of the expression statement. There is also no spec for annotating the left-hand side in an assignment expression.
One proposal is to allow (@A @B f(...)); and (@A @B x=e); for the former, and (@A @B l) = e for the latter. I'm fairly certain that this will not introduce ambiguities into the grammar, and it is fairly clear to the user.