Skip to content

Commit 779470a

Browse files
committed
https://github.com/ruby/ruby/pull/15498/commits/74ea62b99ebbaf68343224ba56e3e21892a4cd0c
1 parent 0de72f6 commit 779470a

3 files changed

Lines changed: 43 additions & 6 deletions

File tree

src/prism.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,12 +1180,9 @@ pm_check_value_expression(pm_parser_t *parser, pm_node_t *node) {
11801180
if (parser->version >= PM_OPTIONS_VERSION_CRUBY_4_0) {
11811181
pm_node_t *body_part;
11821182
PM_NODE_LIST_FOREACH(&cast->body, index, body_part) {
1183-
switch (PM_NODE_TYPE(body_part)) {
1184-
case PM_CASE_VOID_VALUE:
1185-
if (void_node == NULL) void_node = body_part;
1186-
break;
1187-
default: break;
1188-
}
1183+
if (index == cast->body.size - 1) break;
1184+
pm_node_t *vn = pm_check_value_expression(parser, body_part);
1185+
if (vn) return vn;
11891186
}
11901187
}
11911188

test/prism/errors/singleton_method_for_literals.txt renamed to test/prism/errors/3.3-3.4/singleton_method_for_literals.txt

File renamed without changes.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
def (1).g; end
2+
^ cannot define singleton method for literals
3+
def ((a; 1)).foo; end
4+
^ cannot define singleton method for literals
5+
def ((return; 1)).bar; end
6+
^~~~~~ unexpected void value expression
7+
^ cannot define singleton method for literals
8+
def (((1))).foo; end
9+
^ cannot define singleton method for literals
10+
def (__FILE__).foo; end
11+
^~~~~~~~ cannot define singleton method for literals
12+
def (__ENCODING__).foo; end
13+
^~~~~~~~~~~~ cannot define singleton method for literals
14+
def (__LINE__).foo; end
15+
^~~~~~~~ cannot define singleton method for literals
16+
def ("foo").foo; end
17+
^~~~~ cannot define singleton method for literals
18+
def (3.14).foo; end
19+
^~~~ cannot define singleton method for literals
20+
def (3.14i).foo; end
21+
^~~~~ cannot define singleton method for literals
22+
def (:foo).foo; end
23+
^~~~ cannot define singleton method for literals
24+
def (:'foo').foo; end
25+
^~~~~~ cannot define singleton method for literals
26+
def (:'f{o}').foo; end
27+
^~~~~~~ cannot define singleton method for literals
28+
def ('foo').foo; end
29+
^~~~~ cannot define singleton method for literals
30+
def ("foo").foo; end
31+
^~~~~ cannot define singleton method for literals
32+
def ("#{fo}o").foo; end
33+
^~~~~~~~ cannot define singleton method for literals
34+
def (/foo/).foo; end
35+
^~~~~ cannot define singleton method for literals
36+
def (/f#{oo}/).foo; end
37+
^~~~~~~~ cannot define singleton method for literals
38+
def ([1]).foo; end
39+
^~~ cannot define singleton method for literals
40+

0 commit comments

Comments
 (0)