diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-11-30 00:15:29 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-11-30 00:15:29 +0900 |
commit | d1ef4fd08e60adcbcb4feeb55f767ff3d80b65a0 (patch) | |
tree | 99744a28497edc5c632b01d840b7fc4fa47576f5 /parse.y | |
parent | 36da0b3da1aed77e0dffb3f54038f01ff574972b (diff) | |
download | ruby-d1ef4fd08e60adcbcb4feeb55f767ff3d80b65a0.tar.gz |
Make single line pattern matching void expression
Instead of returning `nil`, raise a syntax error if its value is
used. [Feature #16355]
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -10740,6 +10740,17 @@ value_expr_check(struct parser_params *p, NODE *node) case NODE_RETRY: return void_node ? void_node : node; + case NODE_CASE3: + if (!node->nd_body || nd_type(node->nd_body) != NODE_IN) { + compile_error(p, "unexpected node"); + return NULL; + } + if (node->nd_body->nd_body) { + return NULL; + } + /* single line pattern matching */ + return void_node ? void_node : node; + case NODE_BLOCK: while (node->nd_next) { node = node->nd_next; |