Skip to content

Commit d70b6ee

Browse files
authored
Merge pull request #2249 from Shopify/at-remove-todo-call
Remove call to `Any#todo!` from C parser
2 parents 5b64e6c + 8b80ea8 commit d70b6ee

File tree

6 files changed

+15
-6
lines changed

6 files changed

+15
-6
lines changed

config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ nodes:
214214
- name: location
215215
- name: RBS::Types::Bases::Any
216216
fields:
217+
- name: todo
217218
- name: location
218219
- name: RBS::Types::Bases::Bool
219220
fields:

ext/rbs_extension/parser.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -993,12 +993,10 @@ static VALUE parse_simple(parserstate *state) {
993993
return rbs_bases_void(rbs_location_current_token(state));
994994
}
995995
case kUNTYPED: {
996-
return rbs_bases_any(rbs_location_current_token(state));
996+
return rbs_bases_any(false, rbs_location_current_token(state));
997997
}
998998
case k__TODO__: {
999-
VALUE type = rbs_bases_any(rbs_location_current_token(state));
1000-
rb_funcall(type, rb_intern("todo!"), 0);
1001-
return type;
999+
return rbs_bases_any(true, rbs_location_current_token(state));
10021000
}
10031001
case tINTEGER: {
10041002
VALUE literal = rb_funcall(

include/rbs/ruby_objs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ VALUE rbs_method_type(VALUE type_params, VALUE type, VALUE block, VALUE location
4444
VALUE rbs_namespace(VALUE path, VALUE absolute);
4545
VALUE rbs_type_name(VALUE namespace, VALUE name);
4646
VALUE rbs_alias(VALUE name, VALUE args, VALUE location);
47-
VALUE rbs_bases_any(VALUE location);
47+
VALUE rbs_bases_any(VALUE todo, VALUE location);
4848
VALUE rbs_bases_bool(VALUE location);
4949
VALUE rbs_bases_bottom(VALUE location);
5050
VALUE rbs_bases_class(VALUE location);

lib/rbs/types.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,16 @@ def with_nonreturn_void?
107107
class Bool < Base; end
108108
class Void < Base; end
109109
class Any < Base
110+
def initialize(location:, todo: false)
111+
super(location: location)
112+
todo! if todo
113+
end
114+
110115
def to_s(level=0)
111116
@string || "untyped"
112117
end
113118

119+
# @deprecated: this method is now called from the constructor, do not call it from outside
114120
def todo!
115121
@string = '__todo__'
116122
self

sig/types.rbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ module RBS
113113
class Any < Base
114114
@string: String?
115115

116+
def initialize: (location: Location[bot, bot]?, ?todo: bool) -> void
117+
118+
%a{steep:deprecated}
116119
def todo!: () -> self
117120
end
118121

src/ruby_objs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,9 @@ VALUE rbs_alias(VALUE name, VALUE args, VALUE location) {
502502
);
503503
}
504504

505-
VALUE rbs_bases_any(VALUE location) {
505+
VALUE rbs_bases_any(VALUE todo, VALUE location) {
506506
VALUE _init_kwargs = rb_hash_new();
507+
rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("todo")), todo);
507508
rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
508509

509510
return CLASS_NEW_INSTANCE(

0 commit comments

Comments
 (0)