Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ext/rbs_extension/legacy_location.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ static VALUE location_end_pos(VALUE self) {
}

static rbs_constant_id_t rbs_constant_pool_insert_ruby_symbol(VALUE symbol) {
if (!RB_TYPE_P(symbol, T_SYMBOL)) {
rb_raise(rb_eTypeError, "wrong argument type %" PRIsVALUE " (must be a Symbol)", rb_obj_class(symbol));
}
VALUE name = rb_sym2str(symbol);

// Constants inserted here will never be freed, but that's acceptable because:
Expand Down
10 changes: 10 additions & 0 deletions test/rbs/location_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ def test_location_child
end
end

def test_location_add_required_child_with_invalid_argument
loc = Location.new(buffer, 0, 8)
assert_raise(TypeError) { loc.add_required_child("string", 0...6) }
end

def test_location_add_optional_child_with_invalid_argument
loc = Location.new(buffer, 0, 8)
assert_raise(TypeError) { loc.add_optional_child("string", 0...6) }
end

def test_location_initialize_copy
loc = Location.new(buffer, 0, 8)
loc.add_optional_child(:num, 0...2)
Expand Down
Loading