Commit 65b720e
Interpolated regexp modifiers: options via a leading operand, not (?imx) (#908)
An interpolated regexp carried its literal-syntax modifier letters into
the run-time-assembled source as a `(?imxn…)` prefix. Two bugs:
- `n`/`u`/`e`/`s` are encoding selectors, not Onigmo group options, so
`/#{x}/n` built `(?n)…` and Onigmo raised "undefined group option" —
aborting every interpolated regexp with an encoding modifier (11
ruby/spec language errors).
- Even the valid `i`/`m`/`x` leaked into `Regexp#source`: `/a#{x}/im`
reported `"(?im-x:a…)"` instead of `"a…"`.
`gen_regexp` now decodes the modifiers into the same option word
`const_regexp` builds (Onigmo `i`/`m`/`x` bits + `NOENCODING` / `KCODE_*`
encoding bits) and emits it as a leading Fixnum operand of the
`ConcatRegexp` instruction — the sole producer/consumer pair, so the
operand layout is private. `concatenate_regexp` peels it off, applies the
Onigmo options for real, and fixes the declared encoding from the KCODE
bits (mirroring `const_regexp`). No inline prefix is emitted, so the
source stays verbatim.
ruby/spec language: 38 → 27 failing (−11). The two remaining `/s`
interpolation cases now fail the same way as the pre-existing
non-interpolated `/s` match (Shift_JIS byte-offset mapping through the
lossy-UTF-8 matcher view — a separate capture-encoding limitation), not
the former crash.
Claude-Session: https://claude.ai/code/session_013XLHRVwyWsn5Pp8zgNcZaK
Co-authored-by: Claude <noreply@anthropic.com>1 parent 9406ad2 commit 65b720e
3 files changed
Lines changed: 92 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2231 | 2231 | | |
2232 | 2232 | | |
2233 | 2233 | | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
2234 | 2256 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1945 | 1945 | | |
1946 | 1946 | | |
1947 | 1947 | | |
1948 | | - | |
1949 | | - | |
1950 | | - | |
1951 | | - | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
1952 | 1980 | | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
1953 | 1987 | | |
1954 | 1988 | | |
1955 | 1989 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
748 | 748 | | |
749 | 749 | | |
750 | 750 | | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
751 | 762 | | |
752 | 763 | | |
753 | 764 | | |
| |||
766 | 777 | | |
767 | 778 | | |
768 | 779 | | |
769 | | - | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
770 | 799 | | |
771 | 800 | | |
772 | 801 | | |
773 | 802 | | |
774 | 803 | | |
775 | 804 | | |
776 | | - | |
| 805 | + | |
777 | 806 | | |
778 | | - | |
| 807 | + | |
779 | 808 | | |
780 | 809 | | |
781 | 810 | | |
| |||
0 commit comments