From: "alanwu (Alan Wu) via ruby-core" Date: 2025-03-14T00:22:10+00:00 Subject: [ruby-core:121355] [Ruby master Bug#21184] SyntaxError when combining `in` with inline hash-rocket (`=>`) Issue #21184 has been updated by alanwu (Alan Wu). Status changed from Open to Rejected It's working as [documented](https://docs.ruby-lang.org/en/3.4/syntax/pattern_matching_rdoc.html) > Note that only symbol keys are supported for hash patterns. By the way, the third line that uses `in` uses a wildcard pattern so is essentially assigning to `pattern`: ``` irb(main):003> pattern = { "a" => 1 }; 0 in pattern => true irb(main):004> p pattern 0 ``` ---------------------------------------- Bug #21184: SyntaxError when combining `in` with inline hash-rocket (`=>`) https://bugs.ruby-lang.org/issues/21184#change-112326 * Author: jtannas (Joel Tannas) * Status: Rejected * ruby -v: ruby 3.4.2 (2025-02-15 revision d2930f8e7a) +PRISM [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- I believe the following should be valid syntax but it's throwing a `SyntaxError`: ``` ruby { a: 1 } in { a: 1 } # => true { a: 1 } in { a: Integer } # => true pattern = { "a" => 1 }; { "a" => 1 } in pattern # => true { "a" => 1 } in { "a" => 1 } # => SYNTAX ERROR ``` -- 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/