From: "kddnewton (Kevin Newton) via ruby-core" Date: 2026-11-30T22:03:00+00:00 Subject: [ruby-core:127776] [Ruby Bug#22663] Pattern matching local variables with invalid source encoding Issue #22663 has been reported by kddnewton (Kevin Newton). ---------------------------------------- Bug #22663: Pattern matching local variables with invalid source encoding https://bugs.ruby-lang.org/issues/22663 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Under parse.y, pattern matching can introduce local variables that are invalid in the encoding of the source, as in: ```ruby # encoding: binary match = Object.new def match.deconstruct_keys(k) = { "\u3042": 1 } case match in { "\u3042": } end ``` under prism this results in a syntax error, because `"\u3042"` is not allowed in the binary encoding. Under parse.y this introduces a local variable only accessible through binding. This is very similar to https://bugs.ruby-lang.org/issues/22597, which fortunately we now also reject. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/