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 @@ -228,6 +228,9 @@ static VALUE rbs_new_location_from_loc_range(VALUE buffer, rbs_loc_range rg) {
}

static rbs_constant_id_t rbs_constant_pool_find_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);

return rbs_constant_pool_find(RBS_GLOBAL_CONSTANT_POOL, (const uint8_t *) RSTRING_PTR(name), RSTRING_LEN(name));
Expand Down
5 changes: 5 additions & 0 deletions test/rbs/location_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def test_location_aref
assert_equal "abc", loc[:alpha].source
end

def test_location_aref_invalid_argument
loc = Location.new(buffer, 0, 8)
assert_raise(TypeError) { loc["string"] }
end

def test_location_start_pos
loc = Location.new(buffer, 0, 8)
assert_equal 0, loc.start_pos
Expand Down
Loading