Skip to content

Commit 8893c02

Browse files
committed
more changes
1 parent f2e4500 commit 8893c02

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

lib/rivet/src/checker/call_expr.ri

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ extend Checker {
2020
match left.+ {
2121
.SelfTy(self_ty) -> self.check_ctor_call(self_ty.sym, call_expr),
2222
.Ident(ident) if (ident.is_sym || ident.is_obj) -> match ident.sym is {
23-
ast.TypeSym(type_sym) if type_sym.info is .Trait
23+
ast.TypeSym(mut type_sym) if type_sym.info is .Trait
2424
|| type_sym.info is .Struct || type_sym.info is .String
2525
|| type_sym.info is .Enum -> self.check_ctor_call(type_sym, call_expr),
26-
ast.Func(func_) -> {
26+
ast.Func(mut func_) -> {
2727
call_expr.func_ = func_;
2828
if func_.is_main {
2929
report.error("cannot call to `main` function", ident.pos);
@@ -47,12 +47,12 @@ extend Checker {
4747
},
4848
.Selector(selector) -> if selector.is_path {
4949
match selector.sym is {
50-
ast.TypeSym(s_type_sym) if s_type_sym.info is .Trait
50+
ast.TypeSym(mut s_type_sym) if s_type_sym.info is .Trait
5151
|| s_type_sym.info is .Struct || s_type_sym.info is .String
5252
|| s_type_sym.info is .Enum -> self.check_ctor_call(
5353
s_type_sym, call_expr
5454
),
55-
ast.Func(s_func_) -> {
55+
ast.Func(mut s_func_) -> {
5656
call_expr.func_ = s_func_;
5757
self.check_func_call(s_func_, call_expr);
5858
},
@@ -79,7 +79,7 @@ extend Checker {
7979
);
8080
err.add_help("use the option-check syntax: `foo?.method()` or use `??`: `(foo ?? 5).method()`");
8181
err.emit();
82-
return .Void;
82+
return +mut .Void;
8383
}
8484
if left_sym := selector.left_type.symbol() {
8585
if method := left_sym.find_method(selector.field_name) {
@@ -129,7 +129,7 @@ extend Checker {
129129
);
130130
}
131131
},
132-
.EnumLiteral(enum_lit) -> {
132+
.EnumLiteral(&mut enum_lit) -> {
133133
enum_lit.is_instance = true;
134134
_ = self.check_expr(left);
135135
self.check_ctor_call(enum_lit.sym, call_expr);
@@ -196,12 +196,12 @@ extend Checker {
196196
call_expr.type = if type_sym.info is .Struct(struct_info) && struct_info.is_enum_variant {
197197
call_expr.is_enum_variant = true;
198198
call_expr.enum_variant_sym = type_sym;
199-
.Basic(struct_info.parent)
199+
+mut .Basic(struct_info.parent)
200200
} else {
201-
.Basic(type_sym, pos: call_expr.pos)
201+
+mut .Basic(type_sym, pos: call_expr.pos)
202202
};
203-
match type_sym.info {
204-
.Enum(enum_info) -> {
203+
match type_sym.info.+ {
204+
.Enum(&enum_info) -> {
205205
variant := if call_expr.left is .Selector(selector) {
206206
@as(ast.TypeInfo.Enum, @as(+mut ast.TypeSym, selector.left_sym).info)
207207
.get_variant(selector.field_name)?
@@ -220,7 +220,7 @@ extend Checker {
220220
} else if variant.has_type {
221221
old_expected_type := self.expected_type;
222222
self.expected_type = variant.type;
223-
mut arg0 := call_expr.args[0];
223+
arg0 := call_expr.args[0];
224224
self.check_types(
225225
self.check_expr(arg0.expr), variant.type
226226
) catch |err| {
@@ -247,13 +247,13 @@ extend Checker {
247247
);
248248
}
249249
},
250-
.Trait(trait_info) -> {
250+
.Trait(&mut trait_info) -> {
251251
if call_expr.has_spread_expr {
252252
report.error(
253253
"cannot use spread expression with trait constructor", call_expr.pos
254254
);
255255
} else if call_expr.args.len == 1 {
256-
mut arg0 := call_expr.args[0];
256+
arg0 := call_expr.args[0];
257257
value_t := self.env.comptime_number_to_type(self.check_expr(arg0.expr));
258258
if value_t.symbol()? in trait_info.implements {
259259
trait_info.mark_has_objects();
@@ -272,7 +272,7 @@ extend Checker {
272272
}
273273
},
274274
else -> {
275-
mut initted_fields := maps.MapStringBool();
275+
initted_fields := maps.MapStringBool();
276276
type_fields := type_sym.full_fields();
277277
if !call_expr.has_named_args() {
278278
expr_args_len := call_expr.args.len;
@@ -290,7 +290,7 @@ extend Checker {
290290
return;
291291
}
292292
}
293-
for i, mut arg in call_expr.args {
293+
for i, arg in call_expr.args {
294294
mut field := ast.Field();
295295
if arg.is_named {
296296
if t_field := type_sym.lookup_field(arg.name) {
@@ -340,15 +340,15 @@ extend Checker {
340340
);
341341
continue;
342342
}
343-
match field.type {
343+
match field.type.+ {
344344
.Pointer, .Rawptr if !was_initted -> report.warn(
345345
"field `{}` of type `{}` must be initialized".fmt(
346346
field.name, type_sym.name
347347
), call_expr.pos
348348
),
349349
else -> if f_type_sym := field.type.symbol();
350350
f_type_sym.default_value == none {
351-
match f_type_sym.info {
351+
match f_type_sym.info.+ {
352352
.Trait if !was_initted -> report.warn(
353353
"field `{}` of type `{}` must be initialized".fmt(
354354
field.name, type_sym.name
@@ -460,7 +460,7 @@ extend Checker {
460460
}
461461

462462
old_expected_type := self.expected_type;
463-
for i, mut arg in call_expr.args {
463+
for i, arg in call_expr.args {
464464
arg_fn := if func_.is_variadic && i >= func_.args.len - 1 {
465465
func_.args[func_.args.len - 1]
466466
} else {
@@ -491,7 +491,7 @@ extend Checker {
491491
if spread_expr_sym.info is .DynArray || spread_expr_sym.info is .Array
492492
|| spread_expr_sym.info is .Slice {
493493
last_arg_type := func_.args[func_.args.len - 1].type;
494-
spread_t := ast.Type.Variadic(spread_expr_sym.info.elem_type()?);
494+
spread_t := +mut ast.Type.Variadic(spread_expr_sym.info.elem_type()?);
495495
self.check_types(spread_t, last_arg_type) catch |err| {
496496
report.error(err.to_string(), call_expr.spread_expr.position());
497497
};

lib/rivet/src/checker/match_expr.ri

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extend Checker {
99

1010
func check_match(+mut self, match_expr: &mut ast.Expr.Match) -> +mut ast.Type {
1111
old_expected_type := self.expected_type;
12-
match_expr.type = .Void;
12+
match_expr.type = +mut .Void;
1313
if match_expr.branches.len == 1 && match_expr.has_else {
1414
report.error(
1515
"`match` must have at least one non `else` branch",
@@ -29,9 +29,9 @@ extend Checker {
2929
"invalid type `{}` used as `match` condition".fmt(expr_type),
3030
match_expr.expr.position()
3131
);
32-
return .Void;
32+
return +mut .Void;
3333
}
34-
ast.TypeSym()
34+
+mut ast.TypeSym()
3535
};
3636
if match_expr.expr is .Guard(guard_expr) {
3737
if guard_expr.vars.len == 1 {
@@ -43,7 +43,7 @@ extend Checker {
4343
types.push(var_.type);
4444
}
4545
expr_sym = self.env.universe.add_or_get_tuple(types);
46-
expr_type = .Tuple(types, expr_sym);
46+
expr_type = +mut .Tuple(types, expr_sym);
4747
}
4848
} else {
4949
if match_expr.is_typematch && !(expr_sym.info is .Enum
@@ -60,12 +60,12 @@ extend Checker {
6060
}
6161
}
6262

63-
mut branch_exprs := maps.MapStringUint();
63+
branch_exprs := maps.MapStringUint();
6464
match_expr.expected_type = self.expected_type;
6565
for ib, &mut branch in match_expr.branches {
6666
if !branch.is_else {
6767
self.expected_type = expr_type;
68-
for i, mut pattern in branch.patterns {
68+
for i, pattern in branch.patterns {
6969
pattern_t := self.check_expr(pattern);
7070
if i == 0 {
7171
branch.var_type = pattern_t;
@@ -109,7 +109,7 @@ extend Checker {
109109
} else if branch_var.type.is_boxed() {
110110
report.error("cannot take the address of a boxed value", branch_var.pos);
111111
}
112-
branch_var.type = .Pointer(branch_var.type, branch_var.is_mut);
112+
branch_var.type = +mut .Pointer(branch_var.type, branch_var.is_mut);
113113
} else {
114114
branch.scope.update_is_hidden_ref(
115115
branch_var.name, branch_var.is_mut
@@ -137,7 +137,7 @@ extend Checker {
137137
}
138138
self.expected_type = old_expected_type;
139139
}
140-
mut branch_t := ast.Type.Void;
140+
mut branch_t := +mut ast.Type.Void;
141141
if ib == 0 {
142142
branch_t = self.check_expr(branch.expr);
143143
if match_expr.expected_type is .Void {

0 commit comments

Comments
 (0)