summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryui-knk <[email protected]>2024-01-05 19:45:19 +0900
committerYuichiro Kaneko <[email protected]>2024-02-10 09:23:17 +0900
commitbf72cb84ca52bc062cc1711c03622ed6c928fed8 ()
treea5e17e57e10fe9db150d04c7fd1946ab0a2529b0
parente7b0a01002323d9ed8eed9abca2a4979ebe9ae32 (diff)
Include the first constant name into `Ractor::IsolationError` message
If lhs of assignment is top-level constant reference, the first constant name is omitted from error message. This commit fixes it. ``` # shareable_constant_value: literal ::C = ["Not " + "shareable"] # Before # => cannot assign unshareable object to (Ractor::IsolationError) # After # => cannot assign unshareable object to ::C (Ractor::IsolationError) ```
-rw-r--r--ruby_parser.c1
-rw-r--r--test/ruby/test_parse.rb27
2 files changed, 27 insertions, 1 deletions
@@ -1060,6 +1060,7 @@ rb_node_const_decl_val(const NODE *node)
}
else if (n && nd_type_p(n, NODE_COLON3)) {
// ::Const::Name
rb_ary_push(path, rb_str_new(0, 0));
}
else {
@@ -1537,12 +1537,37 @@ x = __ENCODING__
end
def test_shareable_constant_value_unshareable_literal
- assert_raise_separately(Ractor::IsolationError, /unshareable/,
"#{<<~"begin;"}\n#{<<~'end;'}")
begin;
# shareable_constant_value: literal
C = ["Not " + "shareable"]
end;
end
def test_shareable_constant_value_nonliteral