Skip to content

Commit 2fe2f76

Browse files
committed
Set unchecked during node initialization
Signed-off-by: Alexandre Terrasa <[email protected]>
1 parent 0bf824e commit 2fe2f76

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

ext/rbs_extension/parser.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ static VALUE parse_type_params(parserstate *state, range *rg, bool module_type_p
11581158
rg->start = state->current_token.range.start;
11591159

11601160
while (true) {
1161-
bool unchecked = false;
1161+
VALUE unchecked = Qfalse;
11621162
VALUE variance = ID2SYM(rb_intern("invariant"));
11631163
VALUE upper_bound = Qnil;
11641164
VALUE default_type = Qnil;
@@ -1170,7 +1170,7 @@ static VALUE parse_type_params(parserstate *state, range *rg, bool module_type_p
11701170
range unchecked_range = NULL_RANGE;
11711171
if (module_type_params) {
11721172
if (state->next_token.type == kUNCHECKED) {
1173-
unchecked = true;
1173+
unchecked = Qtrue;
11741174
parser_advance(state);
11751175
unchecked_range = state->current_token.range;
11761176
}
@@ -1245,11 +1245,7 @@ static VALUE parse_type_params(parserstate *state, range *rg, bool module_type_p
12451245
rbs_loc_add_optional_child(loc, INTERN("upper_bound"), upper_bound_range);
12461246
rbs_loc_add_optional_child(loc, INTERN("default"), default_type_range);
12471247

1248-
VALUE param = rbs_ast_type_param(name, variance, upper_bound, default_type, location);
1249-
1250-
if (unchecked) {
1251-
rb_funcall(param, rb_intern("unchecked!"), 0);
1252-
}
1248+
VALUE param = rbs_ast_type_param(name, variance, upper_bound, default_type, unchecked, location);
12531249

12541250
melt_array(&params);
12551251
rb_ary_push(params, param);

lib/rbs/ast/type_param.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ module AST
55
class TypeParam
66
attr_reader :name, :variance, :location, :upper_bound_type, :default_type
77

8-
def initialize(name:, variance:, upper_bound:, location:, default_type: nil)
8+
def initialize(name:, variance:, upper_bound:, location:, default_type: nil, unchecked: false)
99
@name = name
1010
@variance = variance
1111
@upper_bound_type = upper_bound
1212
@location = location
13-
@unchecked = false
1413
@default_type = default_type
14+
@unchecked = unchecked
1515
end
1616

1717
def upper_bound

0 commit comments

Comments
 (0)