[#72745] [Ruby trunk - Misc #11876] [Closed] Scheduled maintenance 2016/01/01 — shibata.hiroshi@...
Issue #11876 has been updated by Hiroshi SHIBATA.
shibata.hiroshi@gmail.com wrote:
[#72824] [Ruby trunk - Bug #11973] IO#advise should raise NotImplementedError on platforms that do not support that call — git@...
Issue #11973 has been updated by Chuck Remes.
[#72954] [Ruby trunk - Feature #12010] [Assigned] Exclude dot and dotdot from Dir#each — naruse@...
Issue #12010 has been reported by Yui NARUSE.
naruse@airemix.jp wrote:
[#73313] [Ruby trunk - Bug #12007] [Open] Newly added Unicode data file doesn't get downloaded — shugo@...
Issue #12007 has been updated by Shugo Maeda.
[#73372] [Ruby trunk - Misc #12004] Code of Conduct — benton@...
Issue #12004 has been updated by Benton Barnett.
On Sun, Jan 24, 2016 at 5:13 PM, <benton@bentonbarnett.com> wrote:
[#73421] [Ruby trunk - Misc #12004] Code of Conduct — nekocat432@...
Issue #12004 has been updated by Ruby Dino.
I’m sorry, but this, like the code of merit, is merely a derailing tactic.
On 2016/01/26 01:32, Austin Ziegler wrote:
On Tue, Jan 26, 2016 at 12:25 AM, Martin J. Dürst <duerst@it.aoyama.ac.jp>
[#73491] [Ruby trunk - Misc #12004] Code of Conduct — git@...
Issue #12004 has been updated by Chuck Remes.
They will never provide any numbers because they are not engineers and they
Coraline is a panelist on Ruby rogues and a very well respected member of
OK, sorry for previous comment. Let's try this way.
On Tue, Jan 26, 2016 at 5:15 PM, Andrew Kirilenko <
[#73558] [Ruby trunk - Misc #12004] Code of Conduct — andrew.kirilenko@...
Issue #12004 has been updated by Andrew Kirilenko.
Andrew, please stop digging. Your hole is only getting deeper.
>Andrew, please stop digging. Your hole is only getting deeper.
[#73586] [Ruby trunk - Misc #12004] Code of Conduct — andrew@...
Issue #12004 has been updated by Andrew Vit.
[#73593] [Ruby trunk - Bug #12034] RegExp does not respect file encoding directive — nobu@...
Issue #12034 has been updated by Nobuyoshi Nakada.
[ruby-core:72870] [Ruby trunk - Bug #11991] `Symbol#match` returns the match position, unlike `String#match` and `Regexp#match`
Issue #11991 has been updated by Nobuyoshi Nakada.
Seems a bug, but ["spec-style" tests](https://github.com/ruby/spec/blob/master/core/symbol/match_spec.rb) seems depending on the current behavior.
~~~diff
diff --git i/string.c w/string.c
index e4b323d..864f6c4 100644
--- i/string.c
+++ w/string.c
@@ -9253,7 +9253,6 @@ sym_casecmp(VALUE sym, VALUE other)
/*
* call-seq:
* sym =~ obj -> fixnum or nil
- * sym.match(obj) -> fixnum or nil
*
* Returns <code>sym.to_s =~ obj</code>.
*/
@@ -9266,6 +9265,19 @@ sym_match(VALUE sym, VALUE other)
/*
* call-seq:
+ * sym.match(obj) -> MatchData or nil
+ *
+ * Returns <code>sym.to_s.match(obj)</code>.
+ */
+
+static VALUE
+sym_match_m(int argc, VALUE *argv, VALUE sym)
+{
+ return rb_str_match_m(argc, argv, rb_sym2str(sym));
+}
+
+/*
+ * call-seq:
* sym[idx] -> char
* sym[b, n] -> string
* sym.slice(idx) -> char
@@ -9593,7 +9605,7 @@ Init_String(void)
rb_define_method(rb_cSymbol, "length", sym_length, 0);
rb_define_method(rb_cSymbol, "size", sym_length, 0);
rb_define_method(rb_cSymbol, "empty?", sym_empty, 0);
- rb_define_method(rb_cSymbol, "match", sym_match, 1);
+ rb_define_method(rb_cSymbol, "match", sym_match_m, -1);
rb_define_method(rb_cSymbol, "upcase", sym_upcase, -1);
rb_define_method(rb_cSymbol, "downcase", sym_downcase, -1);
diff --git i/test/ruby/test_symbol.rb w/test/ruby/test_symbol.rb
index 8960bec..f498fec 100644
--- i/test/ruby/test_symbol.rb
+++ w/test/ruby/test_symbol.rb
@@ -246,6 +246,30 @@
assert_equal(:fOo, :FoO.swapcase)
end
+ def test_MATCH # '=~'
+ assert_equal(10, :"FeeFieFoo-Fum" =~ /Fum$/)
+ assert_equal(nil, "FeeFieFoo-Fum" =~ /FUM$/)
+
+ o = Object.new
+ def o.=~(x); x + "bar"; end
+ assert_equal("foobar", :"foo" =~ o)
+
+ assert_raise(TypeError) { :"foo" =~ "foo" }
+ end
+
+ def test_match_method
+ assert_equal("bar", :"foobarbaz".match(/bar/).to_s)
+
+ o = Regexp.new('foo')
+ def o.match(x, y, z); x + y + z; end
+ assert_equal("foobarbaz", :"foo".match(o, "bar", "baz"))
+ x = nil
+ :"foo".match(o, "bar", "baz") {|y| x = y }
+ assert_equal("foobarbaz", x)
+
+ assert_raise(ArgumentError) { :"foo".match }
+ end
+
def test_symbol_poped
assert_nothing_raised { eval('a = 1; :"#{ a }"; 1') }
end
~~~
----------------------------------------
Bug #11991: `Symbol#match` returns the match position, unlike `String#match` and `Regexp#match`
https://bugs.ruby-lang.org/issues/11991#change-56103
* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee:
* ruby -v:
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
`String#match` and `Regexp#match` return a `MatchData` when match succeeds:
~~~RUBY
"".match(//) # => #<MatchData "">
//.match("") # => #<MatchData "">
//.match(:"") # => #<MatchData "">
~~~
But `Symbol#match` returns the match position (like `String#=~`):
~~~RUBY
:"".match(//) # => 0
~~~
Thus, `Symbol#match` behaves differently from `String#match` and `Regexp#match`. This is the documented behavior, but it may be a bug (together with the documentation).
On the other hand, if it is not a bug, what is the rationale?
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>