diff --git a/lib/rivet/src/ast/Attributes.ri b/lib/rivet/src/ast/Attributes.ri index 166c8a0c6..f1319531b 100644 --- a/lib/rivet/src/ast/Attributes.ri +++ b/lib/rivet/src/ast/Attributes.ri @@ -37,7 +37,7 @@ pub struct Attribute { pub struct Attributes { pub mut attributes: []Attribute; - pub func add(mut self, attribute: Attribute) -> ! { + pub func add(&mut self, attribute: Attribute) -> ! { if self.has(attribute.name) { throw AttributeDuplicatedError(attribute.name); } diff --git a/lib/rivet/src/builder/mod.ri b/lib/rivet/src/builder/mod.ri index c51eef75f..73a60e3f3 100644 --- a/lib/rivet/src/builder/mod.ri +++ b/lib/rivet/src/builder/mod.ri @@ -149,7 +149,7 @@ pub struct Builder { } func import_modules_from_decls( - mut self, sf: ^mut ast.SourceFile, decls: []^mut ast.Decl + &mut self, sf: ^mut ast.SourceFile, decls: []^mut ast.Decl ) -> ! { for decl in decls { if decl is .Import(&mut import_decl) { @@ -181,7 +181,7 @@ pub struct Builder { } func load_module( - mut self, path: string, alias_name: string, file_path: string, pos: token.Pos + &mut self, path: string, alias_name: string, file_path: string, pos: token.Pos ) -> !ast.ImportedMod { mut mod := self.load_module_files(alias_name, path, file_path)!; if mod.found { diff --git a/lib/rivet/src/checker/builtin_call.ri b/lib/rivet/src/checker/builtin_call.ri index cef443224..db1dd7d48 100644 --- a/lib/rivet/src/checker/builtin_call.ri +++ b/lib/rivet/src/checker/builtin_call.ri @@ -20,14 +20,14 @@ extend Checker { b_func_args_len, builtin_call.args.len ); if builtin_call.args.len < b_func_args_len { - err := report.error_builder( + mut err := report.error_builder( "too few arguments to builtin function `{}`".fmt(builtin_call.name), builtin_call.pos ); err.add_note(expr_msg); err.emit(); } else if builtin_call.args.len > b_func.args.len { - err := report.error_builder( + mut err := report.error_builder( "too many arguments to builtin function `{}`".fmt(builtin_call.name), builtin_call.pos ); diff --git a/lib/rivet/src/checker/call_expr.ri b/lib/rivet/src/checker/call_expr.ri index 8af9a46cb..67bb82846 100644 --- a/lib/rivet/src/checker/call_expr.ri +++ b/lib/rivet/src/checker/call_expr.ri @@ -74,7 +74,7 @@ extend Checker { // call methods selector.left_type = self.check_expr(selector.left); if selector.left_type is .Option { - err := report.error_builder( + mut err := report.error_builder( "option value cannot be called directly", selector.left.position() ); err.add_help("use the option-check syntax: `foo?.method()` or use `??`: `(foo ?? 5).method()`"); @@ -95,7 +95,7 @@ extend Checker { selector.field_type = field.type; self.check_func_call(f_func.symbol(), call_expr); } else { - err := report.error_builder( + mut err := report.error_builder( "type `{}` has no method `{}`".fmt( left_sym.name, selector.field_name ), selector.field_pos @@ -143,7 +143,7 @@ extend Checker { if call_expr.err_handler.is_propagate { if !(self.cur_func.is_main || self.inside_test || self.inside_var_decl || self.cur_func.ret_type is .Result) { - err := report.error_builder( + mut err := report.error_builder( "cannot propagate the result value", call_expr.err_handler.pos ); err.add_note( @@ -175,7 +175,7 @@ extend Checker { ); } } else if call_expr.type is .Result && !self.inside_guard_expr { - err := report.error_builder( + mut err := report.error_builder( "{} `{}` returns a result".fmt( call_expr.func_.type_of(), call_expr.func_.name ), call_expr.pos @@ -277,7 +277,7 @@ extend Checker { if !call_expr.has_named_args() { expr_args_len := call_expr.args.len; if expr_args_len > type_fields.len { - err := report.error_builder( + mut err := report.error_builder( "too many arguments to {} `{}`".fmt( type_sym.type_of(), type_sym.name ), call_expr.pos @@ -318,7 +318,7 @@ extend Checker { if call_expr.has_spread_expr { spread_expr_t := self.check_expr(call_expr.spread_expr); if spread_expr_t != call_expr.type { - err := report.error_builder( + mut err := report.error_builder( "expected type `{}`, found `{}`".fmt( call_expr.type, spread_expr_t ), call_expr.spread_expr.position() @@ -445,13 +445,13 @@ extend Checker { if expr_args_len != func_args_len { expr_msg := "expected {} argument(s), found {}".fmt(func_args_len, expr_args_len); if expr_args_len < func_args_len { - err := report.error_builder( + mut err := report.error_builder( "too few arguments to {} `{}`".fmt(kind, func_.name), call_expr.pos ); err.add_note(expr_msg); err.emit(); } else if !func_.is_variadic { - err := report.error_builder( + mut err := report.error_builder( "too many arguments to {} `{}`".fmt(kind, func_.name), call_expr.pos ); err.add_note(expr_msg); diff --git a/lib/rivet/src/checker/decls.ri b/lib/rivet/src/checker/decls.ri index d6daebb2d..84541a5a6 100644 --- a/lib/rivet/src/checker/decls.ri +++ b/lib/rivet/src/checker/decls.ri @@ -235,7 +235,7 @@ extend Checker { } } if func_decl.ret_type is .Pointer && func_decl.abi != .Rivet { - err := report.error_builder( + mut err := report.error_builder( "function `{}` should return an optional pointer".fmt(func_decl.name), func_decl.ret_type.position() ); @@ -276,7 +276,7 @@ extend Checker { ); } } else { - err := report.error_builder( + mut err := report.error_builder( "`never` functions cannot return", func_decl.pos ); @@ -285,7 +285,7 @@ extend Checker { } }, else -> { - err := report.error_builder( + mut err := report.error_builder( "`never` functions cannot return", func_decl.pos ); @@ -294,7 +294,7 @@ extend Checker { } } } else { - err := report.error_builder( + mut err := report.error_builder( "`never` functions cannot be empty", func_decl.pos ); diff --git a/lib/rivet/src/checker/exprs.ri b/lib/rivet/src/checker/exprs.ri index 1b83259e9..2b9b272e7 100644 --- a/lib/rivet/src/checker/exprs.ri +++ b/lib/rivet/src/checker/exprs.ri @@ -88,7 +88,7 @@ extend Checker { if enum_info.is_tagged && !enum_lit.from_is_cmp && !enum_lit.is_instance { if variant.has_type { - err := report.error_builder( + mut err := report.error_builder( "variant `{}` cannot be initialized without arguments".fmt( enum_lit.value ), @@ -176,7 +176,7 @@ extend Checker { ast.Var(var_sym) -> var_sym.type, ast.Func(mut func_sym) -> { if func_sym.abi != .Rivet { - err := report.error_builder( + mut err := report.error_builder( "cannot use an extern function as a value", ident.pos ); err.add_help("wrap the extern function with a function"); @@ -200,7 +200,7 @@ extend Checker { indirect.is_mut = indirect.left_type.is_pointer(); indirect.left_type.ptr_inner() } else { - err := report.error_builder( + mut err := report.error_builder( "invalid indirect for `{}`".fmt(indirect.left_type), indirect.pos ); if indirect.left_type is .Rawptr { @@ -396,7 +396,7 @@ extend Checker { if selector.left_sym is ast.TypeSym(mut type_sym) { if type_sym.info is .Enum(enum_info) { if variant := enum_info.get_variant(selector.field_name); variant.has_type { - err := report.error_builder( + mut err := report.error_builder( "variant `{}` cannot be initialized without arguments".fmt( selector.field_name ), @@ -426,7 +426,7 @@ extend Checker { ast.Const(const_sym) -> const_sym.type, ast.Var(var_sym) -> var_sym.type, else -> { - err := report.error_builder( + mut err := report.error_builder( "unexpected bug for selector expression", selector.pos ); err.add_note("please report this bug, thanks =D"); @@ -445,7 +445,7 @@ extend Checker { } else if sym := left_sym.scope.find(selector.field_name) { if sym is ast.Func(mut func_sym) { if func_sym.is_method { - err := report.error_builder( + mut err := report.error_builder( "cannot take value of method `{}`".fmt(selector.field_name), selector.field_pos ); @@ -453,7 +453,7 @@ extend Checker { err.emit(); ^mut .Void } else { - err := report.error_builder( + mut err := report.error_builder( "cannot take value of associated function `{}`".fmt( selector.field_name ), selector.field_pos @@ -473,7 +473,7 @@ extend Checker { ^mut .Void } } else { - err := report.error_builder( + mut err := report.error_builder( "type `{}` has no field `{}`".fmt( left_sym.name, selector.field_name ), selector.field_pos @@ -529,7 +529,7 @@ extend Checker { }, else -> { if !(index.left_type is .Pointer || index.left_type == self.env.string_t) { - err := report.error_builder( + mut err := report.error_builder( "type `{}` does not support indexing".fmt(index.left_type), index.pos ); @@ -549,7 +549,7 @@ extend Checker { } if index.left_type == self.env.string_t { if index.index is .Range { - err := report.error_builder( + mut err := report.error_builder( "`string` does not support slicing syntax", index.pos ); err.add_help("use `.substr()` instead"); @@ -574,7 +574,7 @@ extend Checker { "operator `~` can only be used with numeric values", unary.pos ), .Minus -> if self.env.is_unsigned_int(unary.type) { - err := report.error_builder( + mut err := report.error_builder( "cannot apply unary operator `-` to type `{expr.typ}`".fmt( unary.type ), unary.pos @@ -635,7 +635,7 @@ extend Checker { if binary.op in [.Plus, .Minus, .Mul, .Div, .Mod, .Xor, .Amp, .Pipe] { if left_type.is_pointer() { - err := report.error_builder( + mut err := report.error_builder( "pointer arithmetic is not allowed", binary.pos ); if binary.op == .Plus { @@ -690,7 +690,7 @@ extend Checker { if left_type is .Option(opt) { if !self.check_compatible_types(right_type, opt.inner) && right_type !is .Never { - err := report.error_builder( + mut err := report.error_builder( "expected type `{}`, found `{}`".fmt(opt.inner, right_type), binary.right.position() ); @@ -719,7 +719,7 @@ extend Checker { || !(left_sym.info is .Enum(enum_info) && enum_info.is_tagged)) && !left_sym.has_method(op_method) { - err := report.error_builder( + mut err := report.error_builder( "cannot use operator `{}` with type `{}`".fmt( binary.op, left_sym.name ), binary.pos @@ -820,7 +820,7 @@ extend Checker { } else if binary.left is .Binary(bin_left) { if bin_left.op != binary.op && bin_left.op in [.LogicalAnd, .LogicalOr] { // use `(a && b) || c` instead of `a && b || c` - err := report.error_builder( + mut err := report.error_builder( "ambiguous boolean expression", binary.pos ); err.add_help( @@ -928,7 +928,7 @@ extend Checker { expr_type := self.check_expr(return_expr.expr); self.expected_type = old_expected_type; self.check_types(expr_type, self.cur_func.ret_type) catch |err| { - err_b := report.error_builder( + mut err_b := report.error_builder( err.to_string(), return_expr.expr.position() ); err_b.add_note( @@ -942,7 +942,7 @@ extend Checker { self.cur_func.ret_type is .Void || (self.cur_func.ret_type is .Result(res_t) && res_t.inner is .Void) ) { - err := report.error_builder( + mut err := report.error_builder( "expected `{}` value in return argument".fmt(self.cur_func.ret_type), return_expr.pos ); @@ -966,7 +966,7 @@ extend Checker { if !(expr_sym == self.env.throwable_sym || expr_sym.implement_trait(self.env.throwable_sym) ) { - err_b := report.error_builder( + mut err_b := report.error_builder( "using an invalid value as an error to throw", throw_expr.expr.position() ); @@ -980,7 +980,7 @@ extend Checker { err_b.emit(); } } else { - err_b := report.error_builder( + mut err_b := report.error_builder( "{} `{}` cannot throws errors".fmt( self.cur_func.kind(), self.cur_func.name ), throw_expr.expr.position() diff --git a/lib/rivet/src/checker/match_expr.ri b/lib/rivet/src/checker/match_expr.ri index 361fb6d1a..7caeaf2ea 100644 --- a/lib/rivet/src/checker/match_expr.ri +++ b/lib/rivet/src/checker/match_expr.ri @@ -48,7 +48,7 @@ extend Checker { } else { if match_expr.is_typematch && !(expr_sym.info is .Enum || expr_sym.info is .Trait) { - err := report.error_builder( + mut err := report.error_builder( "invalid type for type-match", match_expr.expr.position() ); err.add_note("expected trait value, found `{}`", expr_type); @@ -203,7 +203,7 @@ extend Checker { return match_expr.expected_type; } - err := report.error_builder("`match` must be exhaustive", match_expr.pos); + mut err := report.error_builder("`match` must be exhaustive", match_expr.pos); if unhandled.len > 0 { mut err_details := "add `match` branches for: "; if unhandled.len < MATCH_EXHAUSTIVE_CUTOFF_LIMIT { diff --git a/lib/rivet/src/checker/mutability.ri b/lib/rivet/src/checker/mutability.ri index 7c34c61ba..8870064df 100644 --- a/lib/rivet/src/checker/mutability.ri +++ b/lib/rivet/src/checker/mutability.ri @@ -120,8 +120,8 @@ extend Checker { if var_info.is_mut { var_info.is_changed = true; } else { - err := if var_info.level == .Argument { - err_b := report.error_builder( + mut err := if var_info.level == .Argument { + mut err_b := report.error_builder( "cannot use variable `{}` as mutable argument".fmt(sym.name), pos ); err_b.add_help( @@ -129,7 +129,7 @@ extend Checker { ); err_b } else { - err_b := report.error_builder( + mut err_b := report.error_builder( "cannot use variable `{}` as mutable value".fmt(sym.name), pos ); err_b.add_help( diff --git a/lib/rivet/src/checker/stmts.ri b/lib/rivet/src/checker/stmts.ri index 23b213e66..980670302 100644 --- a/lib/rivet/src/checker/stmts.ri +++ b/lib/rivet/src/checker/stmts.ri @@ -93,7 +93,7 @@ extend Checker { } self.check_stmt(for_stmt.stmt); } else { - err := report.error_builder( + mut err := report.error_builder( "`{}` is not an iterable type".fmt(iterable_t), for_stmt.iterable.position() ); diff --git a/lib/rivet/src/checker/trait_impl.ri b/lib/rivet/src/checker/trait_impl.ri index bf2d670f6..1b62d53bb 100644 --- a/lib/rivet/src/checker/trait_impl.ri +++ b/lib/rivet/src/checker/trait_impl.ri @@ -44,7 +44,7 @@ extend Checker { )); } if errors.len > 0 { - err := report.error_builder( + mut err := report.error_builder( "type `{}` incorrectly implements method `{}` of trait `{}`".fmt( impltor.qualname(), impl.name, trait_sym.qualname() ), impl.pos @@ -73,7 +73,7 @@ extend Checker { } } if impl_does_not_implemented.len > 0 { - err := report.error_builder( + mut err := report.error_builder( "type `{}` does not implement trait `{}`".fmt( impltor.qualname(), trait_sym.qualname() ), pos diff --git a/lib/rivet/src/checker/types.ri b/lib/rivet/src/checker/types.ri index 4645a10bd..5ad9ba289 100644 --- a/lib/rivet/src/checker/types.ri +++ b/lib/rivet/src/checker/types.ri @@ -24,7 +24,7 @@ extend Checker { if got_t.symbol()? in trait_info.implements { trait_info.mark_has_objects(); } else { - err := report.error_builder( + mut err := report.error_builder( "type `{}` does not implement trait `{}`".fmt( got_t, expected_sym.name ), pos @@ -36,7 +36,7 @@ extend Checker { } } else { self.check_types(got, expected) catch |err| { - err2 := report.error_builder(err.to_string(), pos); + mut err2 := report.error_builder(err.to_string(), pos); err2.add_note( "in argument `{}` of {} `{}`".fmt(arg_name, func_kind, func_name) ); diff --git a/lib/rivet/src/parser/exprs.ri b/lib/rivet/src/parser/exprs.ri index 8b7384435..f7f3afdff 100644 --- a/lib/rivet/src/parser/exprs.ri +++ b/lib/rivet/src/parser/exprs.ri @@ -660,7 +660,7 @@ extend Parser { }; if self.accept(.DotDot) || self.accept(.Ellipsis) { if self.prev_tok.kind == .DotDot { - err := report.error_builder( + mut err := report.error_builder( "`match` only supports inclusive ranges, not exclusive", self.prev_tok.pos ); diff --git a/lib/rivet/src/parser/import.ri b/lib/rivet/src/parser/import.ri index df1429127..acc53a6ea 100644 --- a/lib/rivet/src/parser/import.ri +++ b/lib/rivet/src/parser/import.ri @@ -153,7 +153,7 @@ extend Parser { lbrace_pos += self.tok.pos; self.expect(.Rbrace); if import_list.len == 1 { - warn := report.warn_builder("unnecessary use of braces", lbrace_pos); + mut warn := report.warn_builder("unnecessary use of braces", lbrace_pos); warn.add_help("consider removing those braces"); warn.emit(); } @@ -175,7 +175,7 @@ extend Parser { } else if self.accept(.Mul) { glob = true; } else { - err := report.error_builder( + mut err := report.error_builder( "invalid syntax for unqualified import", mod_path_pos ); err.add_note("expected a single name, a list of names or `*`"); diff --git a/lib/rivet/src/parser/types.ri b/lib/rivet/src/parser/types.ri index 52e8d8303..52a7ccb39 100644 --- a/lib/rivet/src/parser/types.ri +++ b/lib/rivet/src/parser/types.ri @@ -45,7 +45,7 @@ extend Parser { // pointers is_mut := self.accept(.KwMut); if self.tok.kind == .Mul { - err := report.error_builder("cannot declare pointer to pointer", pos + self.tok.pos); + mut err := report.error_builder("cannot declare pointer to pointer", pos + self.tok.pos); err.add_help("use an indexable pointer instead (`[&]T`)"); err.emit(); } @@ -89,7 +89,7 @@ extend Parser { } } if inners.len > 8 { - err := report.error_builder("tuples can have a maximum of 8 types", pos + self.tok.pos); + mut err := report.error_builder("tuples can have a maximum of 8 types", pos + self.tok.pos); err.add_help("you can use a struct instead"); err.emit(); } diff --git a/lib/rivet/src/report/mod.ri b/lib/rivet/src/report/mod.ri index e5cb23af1..54ea5fd49 100644 --- a/lib/rivet/src/report/mod.ri +++ b/lib/rivet/src/report/mod.ri @@ -67,16 +67,16 @@ pub struct ReportBuilder { mut attributes: []Attribute; #[inline] - pub func add_note(mut self, msg: string, args: ...^traits.Stringable) { + pub func add_note(&mut self, msg: string, args: ...^traits.Stringable) { self.attributes.push(Attribute(.Note, msg.fmt(args))); } #[inline] - pub func add_help(mut self, msg: string, args: ...^traits.Stringable) { + pub func add_help(&mut self, msg: string, args: ...^traits.Stringable) { self.attributes.push(Attribute(.Help, msg.fmt(args))); } - pub func emit(mut self) { + pub func emit(&mut self) { if self.kind == .Warn { if report_table.prefs.hide_all_warns { return; diff --git a/lib/rivet/src/resolver/Register.ri b/lib/rivet/src/resolver/Register.ri index bec861e1c..8e7505b98 100644 --- a/lib/rivet/src/resolver/Register.ri +++ b/lib/rivet/src/resolver/Register.ri @@ -371,13 +371,13 @@ pub struct Register { func check_imported_symbol(^self, name: string, pos: token.Pos, is_import: bool) -> bool { if self.source_file.imported_symbols.exists(name) { if is_import { - err := report.error_builder( + mut err := report.error_builder( "another symbol with the name `{}` is already imported".fmt(name), pos ); err.add_help("change the name of the import with `as` (`x as y`)"); err.emit(); } else { - err := report.error_builder( + mut err := report.error_builder( "duplicate symbol `{}` in {} `{}`".fmt( name, self.sym.type_of(), self.sym.name ), pos @@ -387,7 +387,7 @@ pub struct Register { } return false; } else if is_import && self.source_file.mod.scope.exists(name) { - err := report.error_builder( + mut err := report.error_builder( "another symbol with the name `{}` already exists".fmt(name), pos ); err.add_help("change the name of the import with `as` (`x as y`)"); diff --git a/lib/rivet/src/resolver/exprs.ri b/lib/rivet/src/resolver/exprs.ri index c200ab3f0..44ffbb4d2 100644 --- a/lib/rivet/src/resolver/exprs.ri +++ b/lib/rivet/src/resolver/exprs.ri @@ -259,7 +259,7 @@ extend Resolver { } } else if sym := self.env.universe.scope.find(ident.name) { if sym is ast.Module { - err := report.error_builder( + mut err := report.error_builder( "use of non-imported module `{}`".fmt(ident.name), ident.pos ); err.add_help("add an `import` with the path to the module"); @@ -381,7 +381,7 @@ extend Resolver { if self.source_file_abi == sym.abi { self.different_abi_usage_count += 1; } else { - warn := report.warn_builder( + mut warn := report.warn_builder( "using a symbol whose ABI is different from that of the current file", pos ); warn.add_note("`{}` is declared as `extern ({})`", sym.name, sym.abi); diff --git a/lib/rivet/src/resolver/types.ri b/lib/rivet/src/resolver/types.ri index e1c309de4..ed5d263a0 100644 --- a/lib/rivet/src/resolver/types.ri +++ b/lib/rivet/src/resolver/types.ri @@ -35,7 +35,7 @@ extend Resolver { .Array(&mut arr) -> if self.resolve_type(arr.inner) { if arr_size := self.eval_size(arr.size) { if arr_size <= 0 { - err := report.error_builder( + mut err := report.error_builder( "array size cannot be zero or negative", arr.size.position() ); err.add_note("array size {}", arr_size); diff --git a/lib/rivet/src/tokenizer/next.ri b/lib/rivet/src/tokenizer/next.ri index 854052029..5d199ecd7 100644 --- a/lib/rivet/src/tokenizer/next.ri +++ b/lib/rivet/src/tokenizer/next.ri @@ -41,7 +41,7 @@ extend Tokenizer { // decimals with 0 prefix = error if ch == '0' && nextc.is_digit() { self.pos -= 1; - err := self.error_builder( + mut err := self.error_builder( "leading zeros in decimal integer literals are not permitted" ); err.add_help("use an `0o` prefix for octal integers"); @@ -524,7 +524,7 @@ extend Tokenizer { } else { // 6. self.pos -= 1; - err := self.error_builder( + mut err := self.error_builder( "float literals should have a digit after the decimal point" ); err.add_help( @@ -641,18 +641,18 @@ extend Tokenizer { u := ch.as_runes(); if u.len != 1 { if escaped_hex || escaped_unicode { - err := self.error_builder( + mut err := self.error_builder( "invalid character literal (`{}` -> `{}`)".fmt(orig, ch), pos ); err.add_note("escape sequence did not refer to a singular rune"); err.emit(); } else if u.len == 0 { - err := self.error_builder("empty character literal", pos); + mut err := self.error_builder("empty character literal", pos); err.add_help("if you meant to write a string literal, use double quotes"); err.emit(); } else { - err := self.error_builder( + mut err := self.error_builder( "character literal may only contain one codepoint", pos ); err.add_help("if you meant to write a string literal, use double quotes"); diff --git a/lib/rivet/src/utils/depgraph/mod.ri b/lib/rivet/src/utils/depgraph/mod.ri index 7b14a589d..91bc6d58d 100644 --- a/lib/rivet/src/utils/depgraph/mod.ri +++ b/lib/rivet/src/utils/depgraph/mod.ri @@ -80,7 +80,7 @@ pub struct DepGraph { for node in self.nodes { nn.names.set(node.name, node.deps); } - nn_names_it := nn.names.iterator(); + mut nn_names_it := nn.names.iterator(); while k := nn_names_it.next() { mut cycle_names := []string(); if nn.is_cycle.contains(k.key) { @@ -100,7 +100,7 @@ struct NodeNames { mut is_cycle: maps.MapStringBool; mut names: maps.MapStringArrayOfStrings; - func is_part_of_cycle(mut self, name: string, already_seen: []string) -> (bool, []string) { + func is_part_of_cycle(&mut self, name: string, already_seen: []string) -> (bool, []string) { mut seen := false; mut new_already_seen := already_seen.clone(); if val := self.is_cycle.get(name) { diff --git a/lib/rivet/src/utils/maps/mod.ri b/lib/rivet/src/utils/maps/mod.ri index eb2cccb59..256daf589 100644 --- a/lib/rivet/src/utils/maps/mod.ri +++ b/lib/rivet/src/utils/maps/mod.ri @@ -12,7 +12,7 @@ struct StringUint { pub struct MapStringUint { mut pairs: []mut StringUint; - pub func set(mut self, key: string, value: uint) { + pub func set(&mut self, key: string, value: uint) { for &mut pair in self.pairs { if pair.key == key { pair.value = value; @@ -32,7 +32,7 @@ pub struct MapStringUint { return none; } - pub func delete(mut self, key: string) { + pub func delete(&mut self, key: string) { for i, &pair in self.pairs { if pair.key == key { self.pairs.delete(i); @@ -62,7 +62,7 @@ pub struct MapStringArrayOfStringsIterator { mut idx: uint; #[inline] - pub func next(mut self) -> ?StringArrayOfStrings { + pub func next(&mut self) -> ?StringArrayOfStrings { return if self.idx < self.ref.len() { idx := self.idx; self.idx += 1; @@ -80,7 +80,7 @@ pub struct MapStringArrayOfStrings { return MapStringArrayOfStringsIterator(self); } - pub func set(mut self, key: string, value: []string) { + pub func set(&mut self, key: string, value: []string) { for &mut pair in self.pairs { if pair.key == key { pair.value = value; @@ -100,7 +100,7 @@ pub struct MapStringArrayOfStrings { return none; } - pub func delete(mut self, key: string) { + pub func delete(&mut self, key: string) { for i, &pair in self.pairs { if pair.key == key { self.pairs.delete(i); @@ -128,7 +128,7 @@ struct StringBool { pub struct MapStringBool { mut pairs: []mut StringBool; - pub func set(mut self, key: string, value: bool) { + pub func set(&mut self, key: string, value: bool) { for &mut pair in self.pairs { if pair.key == key { pair.value = value; @@ -148,7 +148,7 @@ pub struct MapStringBool { return none; } - pub func delete(mut self, key: string) { + pub func delete(&mut self, key: string) { for i, &pair in self.pairs { if pair.key == key { self.pairs.delete(i); diff --git a/rivetc/src/parser.py b/rivetc/src/parser.py index c7f6dd511..9c65b89ae 100644 --- a/rivetc/src/parser.py +++ b/rivetc/src/parser.py @@ -598,14 +598,14 @@ def parse_func_decl( sc = self.scope self.expect(Kind.Lparen) if self.tok.kind != Kind.Rparen: - # receiver (`self`|`mut self`|`&self`|`&mut self`|`^self`|`^mut self`) + # receiver (`self`|`&self`|`&mut self`|`^self`|`^mut self`) if self.tok.kind == Kind.KwSelf or ( - self.tok.kind in (Kind.Amp, Kind.Xor, Kind.KwMut) + self.tok.kind in (Kind.Amp, Kind.Xor) and self.peek_tok.kind in (Kind.KwMut, Kind.KwSelf) ): is_method = True self_is_ptr = self.accept(Kind.Amp) - self_is_boxed = not self_is_boxed and self.accept(Kind.Xor) + self_is_boxed = not self_is_ptr and self.accept(Kind.Xor) self_is_mut = self.accept(Kind.KwMut) self.expect(Kind.KwSelf) if self.tok.kind != Kind.Rparen: diff --git a/rivetc/src/type.py b/rivetc/src/type.py index 5d822f8f3..4d1fda47d 100644 --- a/rivetc/src/type.py +++ b/rivetc/src/type.py @@ -105,7 +105,7 @@ def __str__(self): if self.is_mut: res = f"^mut {res}" else: - res = f"+{res}" + res = f"^{res}" return res class Boxedptr(TBase):