2632 Commits

Author SHA1 Message Date
nagachika
a260ee3b3d merge revision(s) 31a3aa4e46dd33b5a08708d687ed9f9d3253b55a: [Backport #22450]
[PATCH] [Bug #22450] Preserve do-block binding in control-flow arguments

	Inherited `CMDARG` state made `do` blocks in control-flow arguments
	bind to the wrong call.
2026-11-03 13:55:49 +09:00
nagachika
72aa33a126 merge revision(s) e5132b162737829f744b2b23908b9d08479db977: [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-20 14:09:25 +09:00
nagachika
ee91328658 merge revision(s) 3f7d4bc859f03f4c7ea131af910d1c4ae142586d: [Backport #22183]
[PATCH] [Bug #22183] Preserve `lpar_beg` across interpolation

	Fix unexpected `keyword_do_LAMBDA` inside string interpolation within
	default argument of lambda.
2026-08-09 14:39:23 +09:00
nagachika
f065974c22 merge revision(s) d8444812f42162567502877ff3665105a960eb60: [Backport #22124]
[PATCH] [Bug #22124] Add block to the proper node
2026-08-09 14:39:00 +09:00
nagachika
75ddbe7c27 merge revision(s) 4644e4f2fafe45e2c49f18bc9712d0f5fff3d341: [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-06-14 12:16:08 +09:00
nagachika
0b20039957 merge revision(s) 24a2ba09af13b7c969733ea9370ad59d2442f4c9: [Backport #21985]
[PATCH] [Bug #21985] Include the `-` in the negative numbers location
2026-05-23 15:10:33 +09:00
Nobuyoshi Nakada
8b491169c3 [Bug #21186] multibyte char literal should be a single letter word
[Backport #21186]
2025-03-20 09:38:42 -07:00
Nobuyoshi Nakada
8d2be590ad [Bug #21153] Add missing op-assign to top const in command_asgn
It was defined in `arg` only; add that pattern to `command_asgn` as
well.
2025-02-25 09:05:34 -08:00
Takashi Kokubun
5ba052675f merge revision(s) fb18bb183c24ca82b8f114ed090d62bd69b5df84: [Backport #20989]
[Bug #20989] Ripper: Pass `compile_error`

	For the universal parser, `rb_parser_reg_fragment_check` function is
	shared between the parser and ripper.  However `parser_params` struct
	is partially different, and `compile_error` function depends on that
	part indirectly.
2025-02-13 17:50:05 -08:00
Takashi Kokubun
667a0f9f92
Revert "[Bug #20965] Define it like an ordinary argument" (#12418)
Revert "[Bug #20965] Define `it` like an ordinary argument (#12398)"

Reverts ruby/ruby#12398 as per https://bugs.ruby-lang.org/issues/20970#note-6 and https://bugs.ruby-lang.org/issues/20965#note-7.
We need more time to design the intended behavior, and it's too late for Ruby 3.4.
2024-12-23 04:46:50 +00:00
Nobuyoshi Nakada
7b2ae8df90
[Bug #20969] Pass assignable from ripper
For the universal parser, `rb_reg_named_capture_assign_iter_impl`
function is shared between the parser and ripper.  However
`parser_params` struct is partially different, and `assignable`
function depends on that part indirectly.
2024-12-19 23:20:09 +09:00
Nobuyoshi Nakada
46fec0f62a
[Bug #20965] Define it like an ordinary argument (#12398)
Also fixes [Bug #20955]
2024-12-18 23:12:16 -08:00
ydah
ce2f398386 Remove unused macros from parse.y 2024-12-10 12:21:19 +09:00
ydah
bfb7571d24 Remove minimum Bison version requirement from parse.y
How about removing `%require “version”` since it is a definition to specify the minimum version of Bison and is not needed now that we have completely moved to Lrama?

see: https://www.gnu.org/software/bison/manual/html_node/Require-Decl.html
2024-12-10 11:50:36 +09:00
S.H.
d278d352f9
Introduce inline_primary rule
Introduce inline_primary rule to merge the same BNF pattern
2024-10-25 22:26:29 +09:00
ydah
1c762d9566 [Bug #20789] Fix an invalid syntax error when ->a=1...{}
https://bugs.ruby-lang.org/issues/20789
2024-10-09 23:58:19 +09:00
Nobuyoshi Nakada
f37e6d7f7b
Merge rb_parser_enc_compatible_latter into rb_parser_enc_compatible 2024-10-05 16:07:57 +09:00
Nobuyoshi Nakada
9dbbd0181f
Parser string encoding is always ASCII-compatible 2024-10-05 15:59:44 +09:00
tompng
6743e6285a [Bug #20784] Fix incomplete character syntax followed by EOF 2024-10-05 15:59:01 +09:00
ydah
169a5ee99e Use user defined inline rules user_or_keyword_variable 2024-10-01 23:59:58 +09:00
Nobuyoshi Nakada
86ae409467
[Bug #20764] Refactor argument forwarding in lambda
Reject argument forwarding in lambda:
- without parentheses
- after optional argument(s)
2024-10-01 20:00:22 +09:00
ydah
ac2786757e Use Named Reference 2024-09-30 18:04:41 +09:00
ydah
044e57ed7c Implement SPLAT NODE keyword locations 2024-09-30 18:04:41 +09:00
tompng
b9e225fcbf Allow dot3 in defs singleton 2024-09-28 22:37:44 +09:00
ydah
8f678d6989 Implement OP_ASGN2 NODE locations 2024-09-28 20:53:09 +09:00
Nobuyoshi Nakada
7e19904c88 Remove on RSTRING_END dependency from parser 2024-09-28 01:59:33 +09:00
Nobuyoshi Nakada
94ad2c3fe9 Reduce creating rb_parser_string_t repeatedly for literals.
Since #11698, `parser_str_new` makes `rb_parser_string_t` and `VALUE`
but discards the former, and then `STR_NEW3` makes the same thing
again.
2024-09-27 23:10:14 +09:00
Nobuyoshi Nakada
710d916c32 Add wrapper macros of rb_parser_str_buf_cat 2024-09-27 23:10:14 +09:00
S-H-GAMELINKS
7f83bd3732 Reduce is_ascii_string function dependency for parser
Changed to use `rb_parser_is_ascii_string` function instead of `is_ascii_string` function
2024-09-27 19:34:35 +09:00
ydah
eff16d9302 Implement OP_ASGN1 NODE locations 2024-09-27 18:20:00 +09:00
Nobuyoshi Nakada
80e483afac
Fold rules [ci skip] 2024-09-26 06:05:35 +09:00
Peter Zhu
407f8b8716 Fix memory leak in Ripper for indented heredocs
The allocated parser string is never freed, which causes a memory leak.

The following code leaks memory:

    Ripper.sexp_raw(DATA.read)

    __END__
    <<~EOF
      a
        #{1}
      a
    EOF
2024-09-25 08:56:14 -04:00
ydah
509b577e01 Implement BLOCK_PASS NODE keyword locations 2024-09-25 09:15:43 +09:00
ydah
31a88d1554 Implement RETURN NODE keyword locations 2024-09-25 09:06:42 +09:00
ydah
b811a9a097 Implement CASE3 NODE keyword locations 2024-09-23 09:19:37 +09:00
ydah
5334766beb Implement CASE2 NODE keyword locations 2024-09-23 09:19:37 +09:00
ydah
feac2b4b77 Implement CASE NODE keyword locations 2024-09-23 09:19:37 +09:00
S-H-GAMELINKS
95d26ee41e Reuse dedent_string function in rb_ruby_ripper_dedent_string function
This change is reduce Ruby C API dependency for Universal Parser.
Reuse dedent_string functions in rb_ruby_ripper_dedent_string functions and remove dependencies on rb_str_modify and rb_str_set_len from the parser.
2024-09-22 12:22:20 +09:00
Jeremy Evans
268c72377b
Raise a compile error for break/next/redo inside eval in cases where it is optimized away
In cases where break/next/redo are not valid syntax, they should
raise a SyntaxError even if inside a conditional block that is
optimized away.

Fixes [Bug #20597]

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-09-18 16:54:56 -07:00
Luke Gruber
5d358b660d Fix issue with super and forwarding arguments in prism_compile.c
Fixes [Bug #20720]
2024-09-11 16:41:46 -04:00
ydah
d03e0d1c35 Implement BREAK, NEXT and REDO NODE locations 2024-09-11 18:01:16 +09:00
ydah
4e6091ce09 Implement WHILE and UNTIL NODE locations 2024-09-11 09:28:55 +09:00
ydah
d52e599538 Implement WHEN NODE locations 2024-09-09 10:34:02 +09:00
ydah
32680f543c Implement AND/OR NODE operator locations 2024-09-05 13:03:28 +09:00
ydah
ab18b1b4f5 Implement VALIAS NODE keyword locations 2024-09-04 14:36:35 +09:00
ydah
a2243ee48b Implement ALIAS NODE keyword locations 2024-09-03 22:09:08 +09:00
ydah
af143d8a74 Implement UNDEF NODE keyword locations 2024-09-03 21:15:12 +09:00
yui-knk
c93d07ed74 [Bug #20695] Do not create needless string object in parser
`set_parser_s_value` does nothing in parser therefore no need to
create string object in parser `set_yylval_node`.

# Object allocation

Run `ruby benchmarks/lobsters/benchmark.rb` with the patch

```diff
diff --git a/benchmarks/lobsters/benchmark.rb b/benchmarks/lobsters/benchmark.rb
index 240c50c..6cdd0ac 100644
--- a/benchmarks/lobsters/benchmark.rb
+++ b/benchmarks/lobsters/benchmark.rb
@@ -7,6 +7,8 @@ Dir.chdir __dir__
 use_gemfile

 require_relative 'config/environment'
+printf "allocated_after_load=%d\n", GC.stat(:total_allocated_objects)
+exit
 require_relative "route_generator"

 # For an in-mem DB, we need to load all data on every boot
```

## Before

```
ruby 3.4.0dev (2024-08-31T18:30:25Z master d6fc8f3d57) [arm64-darwin21]
...
allocated_after_load=2143519
```

## After

```
ruby 3.4.0dev (2024-09-01T00:40:04Z fix_bugs_20695 d1bae52f75) [arm64-darwin21]
...
allocated_after_load=1579662
```

## Ruby 3.3.0 for reference

```
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin21]
...
allocated_after_load=1732702
```
2024-09-03 08:40:07 +09:00
Nobuyoshi Nakada
620ce3807b
[Bug #20680] ensure block is always void context 2024-08-25 08:16:54 +09:00
Nobuyoshi Nakada
995b4c329b
Make same structures same 2024-08-20 12:26:02 +09:00