Skip to content

Commit

Permalink
Merge pull request #2249 from Shopify/at-remove-todo-call
Browse files Browse the repository at this point in the history
Remove call to `Any#todo!` from C parser
  • Loading branch information
soutaro authored Jan 28, 2025
2 parents 5b64e6c + 8b80ea8 commit d70b6ee
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ nodes:
- name: location
- name: RBS::Types::Bases::Any
fields:
- name: todo
- name: location
- name: RBS::Types::Bases::Bool
fields:
Expand Down
6 changes: 2 additions & 4 deletions ext/rbs_extension/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,12 +993,10 @@ static VALUE parse_simple(parserstate *state) {
return rbs_bases_void(rbs_location_current_token(state));
}
case kUNTYPED: {
return rbs_bases_any(rbs_location_current_token(state));
return rbs_bases_any(false, rbs_location_current_token(state));
}
case k__TODO__: {
VALUE type = rbs_bases_any(rbs_location_current_token(state));
rb_funcall(type, rb_intern("todo!"), 0);
return type;
return rbs_bases_any(true, rbs_location_current_token(state));
}
case tINTEGER: {
VALUE literal = rb_funcall(
Expand Down
2 changes: 1 addition & 1 deletion include/rbs/ruby_objs.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ VALUE rbs_method_type(VALUE type_params, VALUE type, VALUE block, VALUE location
VALUE rbs_namespace(VALUE path, VALUE absolute);
VALUE rbs_type_name(VALUE namespace, VALUE name);
VALUE rbs_alias(VALUE name, VALUE args, VALUE location);
VALUE rbs_bases_any(VALUE location);
VALUE rbs_bases_any(VALUE todo, VALUE location);
VALUE rbs_bases_bool(VALUE location);
VALUE rbs_bases_bottom(VALUE location);
VALUE rbs_bases_class(VALUE location);
Expand Down
6 changes: 6 additions & 0 deletions lib/rbs/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,16 @@ def with_nonreturn_void?
class Bool < Base; end
class Void < Base; end
class Any < Base
def initialize(location:, todo: false)
super(location: location)
todo! if todo
end

def to_s(level=0)
@string || "untyped"
end

# @deprecated: this method is now called from the constructor, do not call it from outside
def todo!
@string = '__todo__'
self
Expand Down
3 changes: 3 additions & 0 deletions sig/types.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ module RBS
class Any < Base
@string: String?

def initialize: (location: Location[bot, bot]?, ?todo: bool) -> void

%a{steep:deprecated}
def todo!: () -> self
end

Expand Down
3 changes: 2 additions & 1 deletion src/ruby_objs.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,9 @@ VALUE rbs_alias(VALUE name, VALUE args, VALUE location) {
);
}

VALUE rbs_bases_any(VALUE location) {
VALUE rbs_bases_any(VALUE todo, VALUE location) {
VALUE _init_kwargs = rb_hash_new();
rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("todo")), todo);
rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);

return CLASS_NEW_INSTANCE(
Expand Down

0 comments on commit d70b6ee

Please sign in to comment.