Commit 25031c1d

25031c1dd270Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · +2 added

Description

Add regression test for module_function string-param dispatch

Covers the strings-ansi shape from #1034: a module_function :name method whose body calls a string method (gsub with a regex const) on its param, invoked with a string literal. Resolved by 96b21e6 (module_function with explicit method-name arguments) — the param now widens to string instead of staying int and hitting the "0" fallback.

Refs #1034

Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]

Details

Commit
25031c1dd270
Parent
d9c6efb1494d

test/module_function_str_method_param.rbaddedView file

1+# A module_function-promoted method whose body calls a string method
2+# on its param, invoked with a string-literal arg, must route the
3+# param to the string path (not the int "0" NoMethodError fallback).
4+# Mirrors strings-ansi's Strings::ANSI.sanitize gsub-with-regex-const.
5+module Strings
6+ module ANSI
7+ ANSI_MATCHER = /\e\[[0-9;]*m/
8+ def sanitize(string)
9+ string.gsub(ANSI_MATCHER, "")
10+ end
11+ module_function :sanitize
12+ end
13+end
14+puts Strings::ANSI.sanitize("\e[31mRED\e[0m and \e[1mbold\e[0m text")