Project

General

Profile

Actions

Bug #21945

closed

Ripper lexes newline between identifier and `and?` as ignored newline

Bug #21945: Ripper lexes newline between identifier and `and?` as ignored newline

Added by Earlopain (Earlopain _) 2 days ago. Updated about 12 hours ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [x86_64-linux]
[ruby-core:124934]

Description

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.

Updated by nobu (Nobuyoshi Nakada) about 13 hours ago Actions #1

  • Status changed from Open to Closed

Applied in changeset git|55694ad7efc3f8dc6d5c7aefa60ded4c303ed6cf.


[Bug #21945] Correctly handle and? and similar

Updated by nobu (Nobuyoshi Nakada) about 12 hours ago Actions #2

  • Backport changed from 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONTNEED, 4.0: UNKNOWN to 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONTNEED, 4.0: REQUIRED

Updated by nobu (Nobuyoshi Nakada) about 12 hours ago Actions #3

  • Tags set to backport
Actions

Also available in: PDF Atom