string.c: warn non-nil $;
* string.c (rb_str_split_m): warn use of non-nil $;. * string.c (rb_fs_setter): warn when set to non-nil value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
eb3d3dfcc1
commit
4d1f86a1ff
3
NEWS
3
NEWS
@ -36,6 +36,9 @@ sufficient information, see the ChangeLog file or Redmine
|
|||||||
ary[..3] # identical to ary[0..3]
|
ary[..3] # identical to ary[0..3]
|
||||||
where(sales: ..100)
|
where(sales: ..100)
|
||||||
|
|
||||||
|
* Setting <code>$;</code> to non-nil value is warned now. Use of it in
|
||||||
|
String#split is warned too.
|
||||||
|
|
||||||
=== Core classes updates (outstanding ones only)
|
=== Core classes updates (outstanding ones only)
|
||||||
|
|
||||||
Enumerable::
|
Enumerable::
|
||||||
|
6
string.c
6
string.c
@ -7793,6 +7793,9 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
|
|||||||
else if (!(spat = rb_fs_check(spat))) {
|
else if (!(spat = rb_fs_check(spat))) {
|
||||||
rb_raise(rb_eTypeError, "value of $; must be String or Regexp");
|
rb_raise(rb_eTypeError, "value of $; must be String or Regexp");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
rb_warn("$; is set to non-nil value");
|
||||||
|
}
|
||||||
if (split_type != awk) {
|
if (split_type != awk) {
|
||||||
if (BUILTIN_TYPE(spat) == T_STRING) {
|
if (BUILTIN_TYPE(spat) == T_STRING) {
|
||||||
rb_encoding *enc2 = STR_ENC_GET(spat);
|
rb_encoding *enc2 = STR_ENC_GET(spat);
|
||||||
@ -9918,6 +9921,9 @@ rb_fs_setter(VALUE val, ID id, VALUE *var)
|
|||||||
"value of %"PRIsVALUE" must be String or Regexp",
|
"value of %"PRIsVALUE" must be String or Regexp",
|
||||||
rb_id2str(id));
|
rb_id2str(id));
|
||||||
}
|
}
|
||||||
|
if (!NIL_P(val)) {
|
||||||
|
rb_warn("non-nil $; will be deprecated");
|
||||||
|
}
|
||||||
*var = val;
|
*var = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1702,7 +1702,7 @@ CODE
|
|||||||
|
|
||||||
assert_equal([], "".split(//, 1))
|
assert_equal([], "".split(//, 1))
|
||||||
ensure
|
ensure
|
||||||
$; = fs
|
EnvUtil.suppress_warning {$; = fs}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_split_with_block
|
def test_split_with_block
|
||||||
@ -1742,7 +1742,7 @@ CODE
|
|||||||
result = []; "".split(//, 1) {|s| result << s}
|
result = []; "".split(//, 1) {|s| result << s}
|
||||||
assert_equal([], result)
|
assert_equal([], result)
|
||||||
ensure
|
ensure
|
||||||
$; = fs
|
EnvUtil.suppress_warning {$; = fs}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fs
|
def test_fs
|
||||||
@ -1750,7 +1750,7 @@ CODE
|
|||||||
$; = []
|
$; = []
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
|
assert_separately(%W[-W0], "#{<<~"begin;"}\n#{<<~'end;'}")
|
||||||
bug = '[ruby-core:79582] $; must not be GCed'
|
bug = '[ruby-core:79582] $; must not be GCed'
|
||||||
begin;
|
begin;
|
||||||
$; = " "
|
$; = " "
|
||||||
@ -1760,6 +1760,13 @@ CODE
|
|||||||
GC.start
|
GC.start
|
||||||
assert_equal([], "".split, bug)
|
assert_equal([], "".split, bug)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
fs = $;
|
||||||
|
assert_warn(/\$; will be deprecated/) {$; = " "}
|
||||||
|
ensure
|
||||||
|
EnvUtil.suppress_warning {$; = fs}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_split_encoding
|
def test_split_encoding
|
||||||
|
Loading…
x
Reference in New Issue
Block a user