Takashi Kokubun
310533c5a2
merge revision(s) e5132b1627: [Backport #22264 ]
...
[PATCH] [Bug #22264 ] Warn for duplicate keys after leading keyword splat
Leading keyword splats must not suppress duplicate literal key
warnings.
2026-09-14 12:47:14 -07:00
Nobuyoshi Nakada
487b9e94f7
[Bug #22183 ] Preserve lpar_beg across interpolation
...
Fix unexpected `keyword_do_LAMBDA` inside string interpolation within
default argument of lambda.
2026-07-09 15:01:36 -07:00
Nobuyoshi Nakada
48ac72683a
[Bug #22124 ] Add block to the proper node
2026-06-26 14:34:57 -07:00
Takashi Kokubun
926b0ec4ed
merge revision(s) 4644e4f2fa: [Backport #21986 ]
...
[PATCH] [Bug #21986 ] Fix location of numeric literal
When checking for suffixes, do not flush the numeric literal token
even if no suffix is found.
2026-05-11 13:40:35 -07:00
Takashi Kokubun
e4271b554c
merge revision(s) 24a2ba09af: [Backport #21985 ]
...
[PATCH] [Bug #21985 ] Include the `-` in the negative numbers location
2026-05-11 13:40:06 -07:00
Takashi Kokubun
1d3581e18a
merge revision(s) 55694ad7ef: [Backport #21945 ]
...
[Bug #21945 ] Correctly handle `and?` and similar
2026-03-16 11:55:53 -07:00
yui-knk
f81c62be3d
Terminate args_tail_basic rule with a semicolon
...
Semicolon is optional however it clarifies the end of the rule.
2025-12-19 13:39:12 +08:00
Nobuyoshi Nakada
711d14992e
Adjust indents [ci skip]
2025-12-14 16:11:02 +09:00
Yusuke Endoh
129d74c96b
Binding#implicit_parameters, etc. support the implicit "it" parameter
...
[Bug #21049 ]
2025-12-12 23:24:50 +09:00
yui-knk
c5b51bdd8c
[Bug #21712 ] Allow .() call for command with block
...
This commit allows codes like `a b do end.()` and `a b do end&.()`.
2025-12-11 17:35:39 +08:00
yui-knk
056997cbcd
Remove needless ruby2_keywords field from struct rb_args_info
...
`ruby2_keywords` is set only to be `0` in parse.y.
However `args->ruby2_keywords` is initialized with `0` by `MEMZERO`
in `rb_node_args_new` function and `body->param.flags.ruby2_keywords`
is initialized with `0` by `ZALLOC` in `rb_iseq_constant_body_alloc` function,
so `args->ruby2_keywords` does nothing for `body->param.flags.ruby2_keywords`.
2025-12-09 09:09:00 +08:00
yui-knk
576acb9502
Remove FORWARD_ARGS_WITH_RUBY2_KEYWORDS check
...
Because `FORWARD_ARGS_WITH_RUBY2_KEYWORDS` definition was removed
by 4f77d8d328 .
2025-12-09 09:09:00 +08:00
yui-knk
e96bbd718e
Remove needless parse.y new_nil macro
...
In the past parse.y and ripper had different `new_nil` definition
so that `new_nil` returns `nil` for ripper.
```c
// parse.y
#define new_nil(loc) NEW_NIL(loc)
// ripper
#define new_nil(loc) Qnil
```
However Rearchitect Ripper (89cfc15207 )
removed `new_nil` definition for ripper then this commit removes
needless parse.y macro and uses `NEW_NIL` directly.
2025-12-04 08:39:54 +08:00
yui-knk
b79ef73a3b
Remove needless parse.y value_expr macro
...
In the past parse.y and ripper had different `value_expr` definition
so that `value_expr` does nothing for ripper.
```c
// parse.y
#define value_expr(node) value_expr_gen(p, (node))
// ripper
#define value_expr(node) ((void)(node))
```
However Rearchitect Ripper (89cfc15207 )
removed `value_expr` definition for ripper then this commit removes
needless parse.y macro and uses `value_expr_gen` directly.
2025-12-04 08:39:54 +08:00
yui-knk
dfdc5d40ec
Check and raise semantics errors on nested variables captures in patterns
...
This commit makes these codes to be invalid.
```ruby
case 0
in [a] | 1
end
case 0
in { a: b } | 1
end
case 0
in [{ a: [{ b: [{ c: }] }] }] | 1
end
```
2025-12-03 09:18:22 +08:00
Nobuyoshi Nakada
f4b6a5191c
[Feature #21572 ] Syntax error at capture in alternation pattern
...
Should fail even with `-c` option.
2025-11-14 21:03:04 +09:00
yui-knk
560ec9bfd2
Skip null check for brace_block
...
`brace_block` is `'{' brace_body '}'` or `k_do do_body k_end`.
Both of them are not null so no need to check `$5`.
2025-11-14 10:23:35 +08:00
ydah
5179b7fb3f
Rename mlhs rule to mlhs_items for clarity in parse.y
...
Since `mlhs` is already defined as a nonterminal as follows, using the same name as a parameterizing rule is a bit confusing, so rename the parameterizing rule.
https://github.com/ruby/ruby/blob/8d1c45978329bced97c003d9612b55f578c40a65/parse.y#L3648-L3654
2025-09-21 17:36:45 +09:00
Nobuyoshi Nakada
d2cea4b688
* adjust indents. [ci skip]
2025-09-13 20:10:42 +09:00
Nobuyoshi Nakada
618224adf6
[Feature #20925 ] Support leading logical operators
2025-09-13 15:42:26 +09:00
yui-knk
a8c829e7f0
[Bug #17398 ] Allow private def hello = puts "Hello"
2025-09-13 10:58:07 +08:00
S-H-GAMELINKS
dd4e7801f3
Add NODE SCLASS locations
...
Add locations to struct `RNode_SCLASS`.
memo:
```
@ ProgramNode (location: (1,0)-(1,18))
+-- locals: []
+-- statements:
@ StatementsNode (location: (1,0)-(1,18))
+-- body: (length: 1)
+-- @ SingletonClassNode (location: (1,0)-(1,18))
+-- locals: []
+-- class_keyword_loc: (1,0)-(1,5) = "class"
+-- operator_loc: (1,6)-(1,8) = "<<"
+-- expression:
| @ SelfNode (location: (1,9)-(1,13))
+-- body: nil
+-- end_keyword_loc: (1,15)-(1,18) = "end"
```
2025-08-30 22:41:23 +09:00
Yusuke Endoh
2ccb2de677
Make RubyVM::AST.of return a parent node of NODE_SCOPE
...
This change makes `RubyVM::AST.of` and `.node_id_for_backtrace_location`
return a parent node of NODE_SCOPE (such as NODE_DEFN) instead of the
NODE_SCOPE node itself.
(In future, we may remove NODE_SCOPE, which is a bit hacky AST node.)
This is preparation for [Feature #21543 ].
2025-08-28 12:44:04 +09:00
S-H-GAMELINKS
4775d1ffa8
Add NODE IN locations
...
Add locations to struct `RNode_IN`.
memo:
```bash
> ruby -e 'case 1; in 2 then 3; end' --parser=prism --dump=parsetree
@ ProgramNode (location: (1,0)-(1,24))
+-- locals: []
+-- statements:
@ StatementsNode (location: (1,0)-(1,24))
+-- body: (length: 1)
+-- @ CaseMatchNode (location: (1,0)-(1,24))
+-- predicate:
| @ IntegerNode (location: (1,5)-(1,6))
| +-- IntegerBaseFlags: decimal
| +-- value: 1
+-- conditions: (length: 1)
| +-- @ InNode (location: (1,8)-(1,19))
| +-- pattern:
| | @ IntegerNode (location: (1,11)-(1,12))
| | +-- IntegerBaseFlags: decimal
| | +-- value: 2
| +-- statements:
| | @ StatementsNode (location: (1,18)-(1,19))
| | +-- body: (length: 1)
| | +-- @ IntegerNode (location: (1,18)-(1,19))
| | +-- IntegerBaseFlags: decimal
| | +-- value: 3
| +-- in_loc: (1,8)-(1,10) = "in"
| +-- then_loc: (1,13)-(1,17) = "then"
+-- else_clause: nil
+-- case_keyword_loc: (1,0)-(1,4) = "case"
+-- end_keyword_loc: (1,21)-(1,24) = "end"
```
2025-08-11 22:25:47 +09:00
S-H-GAMELINKS
bcd21053f7
Add MODULE NODE locations
...
Add `keyword_module` amd `keyword_end` locations to struct `RNode_MODULE`.
memo:
```
>ruby --dump=parsetree -e 'module A end'
@ ProgramNode (location: (1,0)-(1,12))
+-- locals: []
+-- statements:
@ StatementsNode (location: (1,0)-(1,12))
+-- body: (length: 1)
+-- @ ModuleNode (location: (1,0)-(1,12))
+-- locals: []
+-- module_keyword_loc: (1,0)-(1,6) = "module"
+-- constant_path:
| @ ConstantReadNode (location: (1,7)-(1,8))
| +-- name: :A
+-- body: nil
+-- end_keyword_loc: (1,9)-(1,12) = "end"
+-- name: :A
```
2025-08-07 01:07:16 +09:00
S-H-GAMELINKS
fd492a45eb
Add DEFINED NODE locations
...
Add keyword_defined locations to struct RNode_DEFINED
2025-07-24 23:30:23 +09:00
S-H-GAMELINKS
f0649ab46a
Make defined? (x;) return expression when using parse.y parser
...
Follow up [Bug #21029 ].
Currently, `defined? (x;)` returns `expression` when using Prism parser.
See:
- https://github.com/ruby/ruby/pull/12949
- https://bugs.ruby-lang.org/issues/21029
However, `defined? (x;)` returns nil when using parse.y, as reported in bug ticket comment and test-all (when using parse.y parser) test result.
This change adds a context flag to track trailing semicolons in defined? scope.
When a trailing semicolon is detected within a defined? scope, the generated AST node is wrapped with NODE_BLOCK.
This change ensures consistent behavior with `defined? (;x)` .
2025-07-16 16:17:10 +09:00
ydah
d60144a490
Implement COLON3 NODE locations
2025-06-15 22:37:20 +09:00
ydah
c584790bde
Implement COLON2 NODE locations
2025-06-15 22:37:20 +09:00
Nobuyoshi Nakada
0e0008da0f
[Bug #21381 ] Refine error messages for it and numbered parameters
2025-06-05 19:21:02 +09:00
ydah
b68172caad
Rename f_optarg to f_opt_arg for consistency in parser rules
2025-04-15 00:39:12 +09:00
ydah
1c8154e5c9
Use call_op2 instead of call_op and tCOLON2
2025-04-14 23:13:57 +09:00
ydah
e255964542
Use user defined parameterizing rules range_expr
2025-04-14 03:21:17 +09:00
ydah
088fd968ed
Add a new non-terminal symbol ternary to tidy up
2025-04-14 03:01:01 +09:00
ydah
e996699820
Refactor assignment rules to remove unnecessary lhs parameter
2025-04-14 01:15:20 +09:00
ydah
a35a101b4c
Change the indent after lhs in generation rules from spaces to tabs
...
Change the indent to match the characters used in other generation rules. This makes it easier to find lhs.
2025-04-13 01:23:39 +09:00
tomoya ishida
a4a6019550
[Bug #21202 ] Fix wrong token concat while tokenizing nested unterminated heredoc ( #13000 )
2025-03-29 20:46:43 +09:00
ydah
549c7fe29d
Adjust indentation for user defined parameterized rule
...
This PR just fixing indentation.
2025-03-29 17:51:19 +09:00
Nobuyoshi Nakada
820c541671
[Bug #21026 ] no singleton method on pseudo variable literal
2025-03-20 17:32:26 +09:00
Nobuyoshi Nakada
1acfb29015
[Bug #21186 ] multibyte char literal should be a single letter word
2025-03-17 23:55:11 +09:00
ydah
dd7deef338
Organize block_param_def by defining opt_block_param for non-terminal symbols
2025-03-14 17:10:33 +09:00
ydah
f5f1951808
Refactor parse.y to replace tIDENTIFIER and tCONSTANT with ident_or_const inline rules
2025-03-14 12:32:03 +09:00
ydah
84f51eb02a
Use user defined parameterizing rules args_tail_basic
2025-03-14 00:20:35 +09:00
ydah
5965978efb
Merge the new_yield method into the rb_node_yield_new method
2025-03-09 11:26:56 +09:00
ydah
caa7eaecc5
Refactor parser rules to remove inline_operation
2025-03-09 02:56:26 +09:00
ydah
24945defa5
Remove redundant semantic action in bvar rule
2025-03-08 22:20:11 +09:00
ydah
eae0fe37c0
Implement CLASS NODE locations
...
The following Location information has been added This is the information required for parse.y to be a universal parser:
```
❯ ruby --parser=prism --dump=parsetree -e "class A < B; end"
@ ProgramNode (location: (1,0)-(1,16))
+-- locals: []
+-- statements:
@ StatementsNode (location: (1,0)-(1,16))
+-- body: (length: 1)
+-- @ ClassNode (location: (1,0)-(1,16))
+-- locals: []
+-- class_keyword_loc: (1,0)-(1,5) = "class"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- constant_path:
| @ ConstantReadNode (location: (1,6)-(1,7))
| +-- name: :A
+-- inheritance_operator_loc: (1,8)-(1,9) = "<"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- superclass:
| @ ConstantReadNode (location: (1,10)-(1,11))
| +-- name: :B
+-- body: nil
+-- end_keyword_loc: (1,13)-(1,16) = "end"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- name: :A
```
2025-03-08 18:26:40 +09:00
ydah
a47e686cb6
Implement POSTEXE NODE locations
...
The following Location information has been added This is the information required for parse.y to be a universal parser:
```
❯ ruby --parser=prism --dump=parsetree -e "END { }"
@ ProgramNode (location: (1,0)-(1,8))
+-- locals: []
+-- statements:
@ StatementsNode (location: (1,0)-(1,8))
+-- body: (length: 1)
+-- @ PostExecutionNode (location: (1,0)-(1,8))
+-- statements: nil
+-- keyword_loc: (1,0)-(1,3) = "END"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- opening_loc: (1,4)-(1,5) = "{"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-- closing_loc: (1,7)-(1,8) = "}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
2025-03-03 11:17:14 +09:00
ydah
c93f30ab67
Use user defined parameterizing rules mlhs
2025-03-02 23:10:45 +09:00
ydah
6c8cdc9c6b
Change superclass rhs to use none
2025-03-02 23:10:17 +09:00