String Templates Expression Statement

Bas Leijdekkers bas.leijdekkers at jetbrains.com
Wed Jul 12 11:27:19 UTC 2023


Hello Amber-dev,

In the String Templates draft specification, I don't see any changes in JLS
Chapter 14.8 Expression Statements. This makes me think that Template
Expressions are not allowed to be used as statements. However javac in
jdk21-ea accepts a Template Expression used as a statement without
reporting any error. (I am using build 21-ea+30-2426). So it appears to me
either the specification or javac is incorrect. Which one should I believe?

Example code:
```
class TemplateExpressionStatement {
    public static void main(String[] args) {
        STR."\{}";
    }
}
```

Bas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230712/8f876785/attachment.htm>


More information about the amber-dev mailing list