[ruby-core:124934] [Ruby Bug#21945] Ripper lexes newline between identifier and `and?` as ignored newline
Issue #21945 has been reported by Earlopain (Earlopain _). ---------------------------------------- Bug #21945: Ripper lexes newline between identifier and `and?` as ignored newline https://bugs.ruby-lang.org/issues/21945 * Author: Earlopain (Earlopain _) * Status: Open * ruby -v: ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [x86_64-linux] * Backport: 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONTNEED, 4.0: UNKNOWN ---------------------------------------- ```rb Ripper.lex("foo\nand?") => [[[1, 0], :on_ident, "foo", CMDARG], [[1, 3], :on_ignored_nl, "\n", CMDARG], [[2, 0], :on_ident, "and?", ARG]] ``` Presumably this is because until the `?` is encountered, it is considered syntax as introduced in https://bugs.ruby-lang.org/issues/20925. The same is true for `and!` and `or`. If any other character is encountered, it lexes correctly like in `foo\nandbar`. -- https://bugs.ruby-lang.org/
Issue #21945 has been updated by k0kubun (Takashi Kokubun). Backport changed from 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONTNEED, 4.0: REQUIRED to 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONTNEED, 4.0: DONE ruby_4_0 commit:1d3581e18a689f0d392686283e340058ac468ffd merged revision(s) commit:55694ad7efc3f8dc6d5c7aefa60ded4c303ed6cf. ---------------------------------------- Bug #21945: Ripper lexes newline between identifier and `and?` as ignored newline https://bugs.ruby-lang.org/issues/21945#change-116714 * Author: Earlopain (Earlopain _) * Status: Closed * ruby -v: ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [x86_64-linux] * Backport: 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONTNEED, 4.0: DONE ---------------------------------------- ```rb Ripper.lex("foo\nand?") => [[[1, 0], :on_ident, "foo", CMDARG], [[1, 3], :on_ignored_nl, "\n", CMDARG], [[2, 0], :on_ident, "and?", ARG]] ``` Presumably this is because until the `?` is encountered, it is considered syntax as introduced in https://bugs.ruby-lang.org/issues/20925. The same is true for `and!` and `or`. If any other character is encountered, it lexes correctly like in `foo\nandbar`. -- https://bugs.ruby-lang.org/
participants (2)
-
Earlopain (Earlopain _) -
k0kubun (Takashi Kokubun)