[Feature #20884] Reserve "Ruby" toplevel name
This commit is contained in:
parent
267ecf5f02
commit
4d86f3bf6d
Notes:
git
2024-12-12 08:45:24 +00:00
@ -101,6 +101,8 @@ firstline, predefined = __LINE__+1, %[\
|
|||||||
$_ LASTLINE
|
$_ LASTLINE
|
||||||
$~ BACKREF
|
$~ BACKREF
|
||||||
$! ERROR_INFO
|
$! ERROR_INFO
|
||||||
|
|
||||||
|
Ruby
|
||||||
]
|
]
|
||||||
|
|
||||||
# VM ID OP Parser Token
|
# VM ID OP Parser Token
|
||||||
|
@ -1326,4 +1326,19 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||||||
assert_ruby_status([env, "-e;"])
|
assert_ruby_status([env, "-e;"])
|
||||||
assert_in_out_err([env, "-W"], "", [], /Free at exit is experimental and may be unstable/)
|
assert_in_out_err([env, "-W"], "", [], /Free at exit is experimental and may be unstable/)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_toplevel_ruby
|
||||||
|
reserved = ["", [], /::Ruby is reserved/]
|
||||||
|
env = {"RUBYOPT"=>""}
|
||||||
|
args = %w[-e Ruby=1]
|
||||||
|
assert_in_out_err([env, *args])
|
||||||
|
assert_in_out_err([env, "-w", *args], *reserved)
|
||||||
|
assert_in_out_err([env, "-W:deprecated", *args], *reserved)
|
||||||
|
assert_in_out_err([env, "-w", "-W:no-deprecated", *args])
|
||||||
|
|
||||||
|
args = ["-e", "class A; Ruby=1; end"]
|
||||||
|
assert_in_out_err([env, *args])
|
||||||
|
assert_in_out_err([env, "-w", *args])
|
||||||
|
assert_in_out_err([env, "-W:deprecated", *args])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -3626,6 +3626,9 @@ const_set(VALUE klass, ID id, VALUE val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (klass == rb_cObject && id == idRuby) {
|
||||||
|
rb_warn_reserved_name_at(3.5, "::Ruby");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user