Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

rename "args" to "arguments"

+1339 -1035
+42 -41
compiler-core/src/analyse.rs
··· 515 515 .expect("Could not find preregistered type for function"); 516 516 let field_map = preregistered_fn.field_map().cloned(); 517 517 let preregistered_type = preregistered_fn.type_.clone(); 518 - let (prereg_args_types, prereg_return_type) = preregistered_type 518 + let (prereg_arguments_types, prereg_return_type) = preregistered_type 519 519 .fn_types() 520 520 .expect("Preregistered type for fn was not a fn"); 521 521 ··· 550 550 has_javascript_external: external_javascript.is_some(), 551 551 }; 552 552 553 - let mut typed_args = Vec::with_capacity(arguments.len()); 554 - for (argument, type_) in arguments.into_iter().zip(&prereg_args_types) { 553 + let mut typed_arguments = Vec::with_capacity(arguments.len()); 554 + for (argument, type_) in arguments.into_iter().zip(&prereg_arguments_types) { 555 555 let argument = argument.set_type(type_.clone()); 556 556 match &argument.names { 557 557 ast::ArgNames::Named { .. } | ast::ArgNames::NamedLabelled { .. } => (), ··· 565 565 } 566 566 } 567 567 568 - typed_args.push(argument); 568 + typed_arguments.push(argument); 569 569 } 570 570 571 571 // We have already registered the function in the `register_value_from_function` ··· 581 581 .remove(&name) 582 582 .expect("Could not find hydrator for fn"); 583 583 584 - let (args, body) = expr_typer.infer_fn_with_known_types( 585 - typed_args.clone(), 584 + let (arguments, body) = expr_typer.infer_fn_with_known_types( 585 + typed_arguments.clone(), 586 586 body, 587 587 Some(prereg_return_type.clone()), 588 588 )?; 589 - let args_types = args.iter().map(|a| a.type_.clone()).collect(); 590 - let type_ = fn_(args_types, body.last().type_()); 589 + let arguments_types = arguments.iter().map(|a| a.type_.clone()).collect(); 590 + let type_ = fn_(arguments_types, body.last().type_()); 591 591 Ok(( 592 592 type_, 593 593 body, ··· 685 685 .map(|(m, f, _)| (m.clone(), f.clone())), 686 686 field_map, 687 687 module: environment.current_module.clone(), 688 - arity: typed_args.len(), 688 + arity: typed_arguments.len(), 689 689 location, 690 690 implementations, 691 691 purity, ··· 713 713 name: Some((name_location, name)), 714 714 publicity, 715 715 deprecation, 716 - arguments: typed_args, 716 + arguments: typed_arguments, 717 717 end_position: end_location, 718 718 return_annotation, 719 719 return_type: preregistered_type ··· 909 909 location, 910 910 name_location, 911 911 name, 912 - arguments: args, 912 + arguments, 913 913 documentation, 914 914 deprecation: constructor_deprecation, 915 915 }| { ··· 926 926 .expect("Could not find preregistered type for function"); 927 927 let preregistered_type = preregistered_fn.type_.clone(); 928 928 929 - let args = match preregistered_type.fn_types() { 930 - Some((args_types, _return_type)) => args 929 + let arguments = match preregistered_type.fn_types() { 930 + Some((arguments_types, _return_type)) => arguments 931 931 .into_iter() 932 - .zip(&args_types) 933 - .map(|(argument, t)| { 932 + .zip(&arguments_types) 933 + .map(|(argument, type_)| { 934 934 if let Some((location, label)) = &argument.label { 935 935 self.check_name_case(*location, label, Named::Label); 936 936 } ··· 939 939 label: argument.label, 940 940 ast: argument.ast, 941 941 location: argument.location, 942 - type_: t.clone(), 942 + type_: type_.clone(), 943 943 doc: argument.doc, 944 944 } 945 945 }) ··· 953 953 location, 954 954 name_location, 955 955 name, 956 - arguments: args, 956 + arguments, 957 957 documentation, 958 958 deprecation: constructor_deprecation, 959 959 } ··· 1071 1071 .register_type_reference_in_call_graph(name.clone()); 1072 1072 1073 1073 let mut field_map_builder = FieldMapBuilder::new(constructor.arguments.len() as u32); 1074 - let mut args_types = Vec::with_capacity(constructor.arguments.len()); 1074 + let mut arguments_types = Vec::with_capacity(constructor.arguments.len()); 1075 1075 let mut fields = Vec::with_capacity(constructor.arguments.len()); 1076 1076 1077 1077 for RecordConstructorArg { ··· 1096 1096 }); 1097 1097 1098 1098 // Register the type for this parameter 1099 - args_types.push(t); 1099 + arguments_types.push(t); 1100 1100 1101 1101 let (label_location, label) = match label { 1102 1102 Some((location, label)) => (*location, Some(label)), ··· 1114 1114 type_.set_custom_type_variant(index as u16); 1115 1115 let type_ = match constructor.arguments.len() { 1116 1116 0 => Arc::new(type_), 1117 - _ => fn_(args_types.clone(), Arc::new(type_)), 1117 + _ => fn_(arguments_types.clone(), Arc::new(type_)), 1118 1118 }; 1119 1119 let constructor_info = ValueConstructorVariant::Record { 1120 1120 documentation: constructor ··· 1266 1266 package: environment.current_package.clone(), 1267 1267 module: self.module_name.to_owned(), 1268 1268 name: name.clone(), 1269 - args: parameters.clone(), 1269 + arguments: parameters.clone(), 1270 1270 inferred_variant: None, 1271 1271 }); 1272 1272 let _ = self.hydrators.insert(name.clone(), hydrator); ··· 1316 1316 let TypeAlias { 1317 1317 location, 1318 1318 publicity, 1319 - parameters: args, 1319 + parameters: arguments, 1320 1320 alias: name, 1321 1321 name_location, 1322 1322 type_ast: resolved_type, ··· 1342 1342 // Use the hydrator to convert the AST into a type, erroring if the AST was invalid 1343 1343 // in some fashion. 1344 1344 let mut hydrator = Hydrator::new(); 1345 - let parameters = self.make_type_vars(args, &mut hydrator, environment); 1345 + let parameters = self.make_type_vars(arguments, &mut hydrator, environment); 1346 1346 let arity = parameters.len(); 1347 1347 let tryblock = || { 1348 1348 hydrator.disallow_new_type_variables(); ··· 1394 1394 1395 1395 fn make_type_vars( 1396 1396 &mut self, 1397 - args: &[SpannedString], 1397 + arguments: &[SpannedString], 1398 1398 hydrator: &mut Hydrator, 1399 1399 environment: &mut Environment<'_>, 1400 1400 ) -> Vec<Arc<Type>> { 1401 - args.iter() 1401 + arguments 1402 + .iter() 1402 1403 .map(|(location, name)| { 1403 1404 self.check_name_case(*location, name, Named::TypeVariable); 1404 1405 match hydrator.add_type_variable(name, environment) { ··· 1428 1429 ) { 1429 1430 let Function { 1430 1431 name, 1431 - arguments: args, 1432 + arguments, 1432 1433 location, 1433 1434 return_annotation, 1434 1435 publicity, ··· 1455 1456 *publicity, 1456 1457 ); 1457 1458 1458 - let mut builder = FieldMapBuilder::new(args.len() as u32); 1459 + let mut builder = FieldMapBuilder::new(arguments.len() as u32); 1459 1460 for Arg { 1460 1461 names, location, .. 1461 - } in args.iter() 1462 + } in arguments.iter() 1462 1463 { 1463 1464 check_argument_names(names, &mut self.problems); 1464 1465 ··· 1473 1474 // must be given in full, so we disallow holes in the annotations. 1474 1475 hydrator.permit_holes(external_erlang.is_none() && external_javascript.is_none()); 1475 1476 1476 - let arg_types = args 1477 + let arguments_types = arguments 1477 1478 .iter() 1478 - .map(|arg| { 1479 + .map(|argument| { 1479 1480 match hydrator.type_from_option_ast( 1480 - &arg.annotation, 1481 + &argument.annotation, 1481 1482 environment, 1482 1483 &mut self.problems, 1483 1484 ) { ··· 1500 1501 } 1501 1502 }; 1502 1503 1503 - let type_ = fn_(arg_types, return_type); 1504 + let type_ = fn_(arguments_types, return_type); 1504 1505 let _ = self.hydrators.insert(name.clone(), hydrator); 1505 1506 1506 1507 let variant = ValueConstructorVariant::ModuleFn { ··· 1514 1515 .as_ref() 1515 1516 .map(|(m, f, _)| (m.clone(), f.clone())), 1516 1517 module: environment.current_module.clone(), 1517 - arity: args.len(), 1518 + arity: arguments.len(), 1518 1519 location: *location, 1519 1520 implementations: *implementations, 1520 1521 purity: *purity, ··· 1632 1633 publicity, 1633 1634 alias, 1634 1635 name_location, 1635 - parameters: args, 1636 + parameters: arguments, 1636 1637 type_ast: resolved_type, 1637 1638 deprecation, 1638 1639 .. ··· 1652 1653 publicity, 1653 1654 alias, 1654 1655 name_location, 1655 - parameters: args, 1656 + parameters: arguments, 1656 1657 type_ast: resolved_type, 1657 1658 type_, 1658 1659 deprecation, ··· 1793 1794 name, 1794 1795 publicity, 1795 1796 deprecation, 1796 - arguments: args, 1797 + arguments, 1797 1798 body, 1798 1799 return_annotation, 1799 1800 end_position: end_location, ··· 1827 1828 .as_ref() 1828 1829 .map(|(m, f, _)| (m.clone(), f.clone())), 1829 1830 module: module_name.clone(), 1830 - arity: args.len(), 1831 + arity: arguments.len(), 1831 1832 location, 1832 1833 implementations, 1833 1834 purity, ··· 1855 1856 name: Some((name_location, name)), 1856 1857 publicity, 1857 1858 deprecation, 1858 - arguments: args, 1859 + arguments, 1859 1860 end_position: end_location, 1860 1861 return_annotation, 1861 1862 return_type, ··· 1888 1889 } 1889 1890 1890 1891 fn custom_type_accessors(constructors: &[TypeValueConstructor]) -> Result<Accessors, Error> { 1891 - let args = get_compatible_record_fields(constructors); 1892 + let arguments = get_compatible_record_fields(constructors); 1892 1893 1893 - let mut shared_accessors = HashMap::with_capacity(args.len()); 1894 + let mut shared_accessors = HashMap::with_capacity(arguments.len()); 1894 1895 1895 - for (index, label, type_) in args { 1896 + for (index, label, type_) in arguments { 1896 1897 let _ = shared_accessors.insert( 1897 1898 label.clone(), 1898 1899 RecordAccessor {
+11 -6
compiler-core/src/ast.rs
··· 1424 1424 // `TypedExpr::Fn{}.find_node()` except we do not return self as a 1425 1425 // fallback. 1426 1426 // 1427 - (Some(ImplicitCallArgOrigin::Use), TypedExpr::Fn { args, body, .. }) => args 1427 + ( 1428 + Some(ImplicitCallArgOrigin::Use), 1429 + TypedExpr::Fn { 1430 + arguments, body, .. 1431 + }, 1432 + ) => arguments 1428 1433 .iter() 1429 - .find_map(|arg| arg.find_node(byte_index)) 1434 + .find_map(|argument| argument.find_node(byte_index)) 1430 1435 .or_else(|| body.iter().find_map(|s| s.find_node(byte_index))), 1431 1436 // In all other cases we're happy with the default behaviour. 1432 1437 // ··· 3156 3161 } 3157 3162 3158 3163 pub fn callback_arguments(&self) -> Option<&Vec<TypedArg>> { 3159 - let TypedExpr::Call { args, .. } = self.call.as_ref() else { 3164 + let TypedExpr::Call { arguments, .. } = self.call.as_ref() else { 3160 3165 return None; 3161 3166 }; 3162 - let callback = args.iter().last()?; 3163 - let TypedExpr::Fn { args, .. } = &callback.value else { 3167 + let callback = arguments.iter().last()?; 3168 + let TypedExpr::Fn { arguments, .. } = &callback.value else { 3164 3169 // The expression might be invalid so we have to return a None here 3165 3170 return None; 3166 3171 }; 3167 - Some(args) 3172 + Some(arguments) 3168 3173 } 3169 3174 } 3170 3175
+4 -4
compiler-core/src/ast/constant.rs
··· 38 38 location: SrcSpan, 39 39 module: Option<(EcoString, SrcSpan)>, 40 40 name: EcoString, 41 - args: Vec<CallArg<Self>>, 41 + arguments: Vec<CallArg<Self>>, 42 42 tag: RecordTag, 43 43 type_: T, 44 44 field_map: Option<FieldMap>, ··· 103 103 .iter() 104 104 .find_map(|element| element.find_node(byte_index)) 105 105 .unwrap_or(Located::Constant(self)), 106 - Constant::Record { args, .. } => args 106 + Constant::Record { arguments, .. } => arguments 107 107 .iter() 108 108 .find_map(|argument| argument.find_node(byte_index)) 109 109 .unwrap_or(Located::Constant(self)), ··· 155 155 .map(|element| element.referenced_variables()) 156 156 .fold(im::hashset![], im::HashSet::union), 157 157 158 - Constant::Record { args, .. } => args 158 + Constant::Record { arguments, .. } => arguments 159 159 .iter() 160 - .map(|arg| arg.value.referenced_variables()) 160 + .map(|argument| argument.value.referenced_variables()) 161 161 .fold(im::hashset![], im::HashSet::union), 162 162 163 163 Constant::BitArray { segments, .. } => segments
+2 -2
compiler-core/src/ast/tests.rs
··· 93 93 package: "mypackage".into(), 94 94 module: "mymod".into(), 95 95 name: "Cat".into(), 96 - args: vec![], 96 + arguments: vec![], 97 97 inferred_variant: None, 98 98 }); 99 99 let variant = ValueConstructorVariant::Record { ··· 762 762 763 763 let TypedExpr::Call { 764 764 fun: called_function, 765 - args: function_arguments, 765 + arguments: function_arguments, 766 766 .. 767 767 } = expr 768 768 else {
+23 -20
compiler-core/src/ast/typed.rs
··· 58 58 location: SrcSpan, 59 59 type_: Arc<Type>, 60 60 kind: FunctionLiteralKind, 61 - args: Vec<TypedArg>, 61 + arguments: Vec<TypedArg>, 62 62 body: Vec1<TypedStatement>, 63 63 return_annotation: Option<TypeAst>, 64 64 purity: Purity, ··· 75 75 location: SrcSpan, 76 76 type_: Arc<Type>, 77 77 fun: Box<Self>, 78 - args: Vec<CallArg<Self>>, 78 + arguments: Vec<CallArg<Self>>, 79 79 }, 80 80 81 81 BinOp { ··· 169 169 /// variable so it can be referred multiple times. 170 170 record_assignment: Option<Box<TypedAssignment>>, 171 171 constructor: Box<Self>, 172 - args: Vec<CallArg<Self>>, 172 + arguments: Vec<CallArg<Self>>, 173 173 }, 174 174 175 175 NegateBool { ··· 193 193 impl TypedExpr { 194 194 pub fn is_println(&self) -> bool { 195 195 let fun = match self { 196 - TypedExpr::Call { fun, args, .. } if args.len() == 1 => fun.as_ref(), 196 + TypedExpr::Call { fun, arguments, .. } if arguments.len() == 1 => fun.as_ref(), 197 197 _ => return false, 198 198 }; 199 199 ··· 351 351 .find_node(byte_index) 352 352 .or_else(|| self.self_if_contains_location(byte_index)), 353 353 354 - Self::Fn { body, args, .. } => args 354 + Self::Fn { 355 + body, arguments, .. 356 + } => arguments 355 357 .iter() 356 358 .find_map(|arg| arg.find_node(byte_index)) 357 359 .or_else(|| body.iter().find_map(|s| s.find_node(byte_index))) 358 360 .or_else(|| self.self_if_contains_location(byte_index)), 359 361 360 - Self::Call { fun, args, .. } => args 362 + Self::Call { fun, arguments, .. } => arguments 361 363 .iter() 362 - .find_map(|arg| arg.find_node(byte_index, fun, args)) 364 + .find_map(|argument| argument.find_node(byte_index, fun, arguments)) 363 365 .or_else(|| fun.find_node(byte_index)) 364 366 .or_else(|| self.self_if_contains_location(byte_index)), 365 367 ··· 392 394 Self::RecordUpdate { 393 395 record_assignment, 394 396 constructor, 395 - args, 397 + arguments, 396 398 .. 397 - } => args 399 + } => arguments 398 400 .iter() 399 - .filter(|arg| arg.implicit.is_none()) 400 - .find_map(|arg| arg.find_node(byte_index, constructor, args)) 401 + .filter(|argument| argument.implicit.is_none()) 402 + .find_map(|argument| argument.find_node(byte_index, constructor, arguments)) 401 403 .or_else(|| { 402 404 record_assignment 403 405 .as_ref() ··· 495 497 496 498 Self::Fn { body, .. } => body.iter().find_map(|s| s.find_statement(byte_index)), 497 499 498 - Self::Call { fun, args, .. } => args 500 + Self::Call { fun, arguments, .. } => arguments 499 501 .iter() 500 - .find_map(|arg| arg.find_statement(byte_index)) 502 + .find_map(|argument| argument.find_statement(byte_index)) 501 503 .or_else(|| fun.find_statement(byte_index)), 502 504 503 505 Self::BinOp { left, right, .. } => left ··· 554 556 555 557 Self::RecordUpdate { 556 558 record_assignment, 557 - args, 559 + arguments, 558 560 .. 559 - } => args 561 + } => arguments 560 562 .iter() 561 563 .filter(|arg| arg.implicit.is_none()) 562 564 .find_map(|arg| arg.find_statement(byte_index)) ··· 726 728 } 727 729 728 730 // Calls are literals if they are records and all the arguemnts are also literals. 729 - Self::Call { fun, args, .. } => { 730 - fun.is_record_builder() && args.iter().all(|argument| argument.value.is_literal()) 731 + Self::Call { fun, arguments, .. } => { 732 + fun.is_record_builder() 733 + && arguments.iter().all(|argument| argument.value.is_literal()) 731 734 } 732 735 733 736 // Variables are literals if they are record constructors that take no arguments. ··· 864 867 && finally.is_pure_value_constructor() 865 868 } 866 869 867 - TypedExpr::Call { fun, args, .. } => { 870 + TypedExpr::Call { fun, arguments, .. } => { 868 871 (fun.is_record_builder() || fun.called_function_purity().is_pure()) 869 - && args 872 + && arguments 870 873 .iter() 871 874 .all(|argument| argument.value.is_pure_value_constructor()) 872 875 } ··· 1029 1032 1030 1033 pub(crate) fn call_arguments(&self) -> Option<&Vec<TypedCallArg>> { 1031 1034 match self { 1032 - TypedExpr::Call { args, .. } => Some(args), 1035 + TypedExpr::Call { arguments, .. } => Some(arguments), 1033 1036 _ => None, 1034 1037 } 1035 1038 }
+33 -21
compiler-core/src/ast/visit.rs
··· 165 165 location: &'ast SrcSpan, 166 166 type_: &'ast Arc<Type>, 167 167 kind: &'ast FunctionLiteralKind, 168 - args: &'ast [TypedArg], 168 + arguments: &'ast [TypedArg], 169 169 body: &'ast Vec1<TypedStatement>, 170 170 return_annotation: &'ast Option<TypeAst>, 171 171 ) { 172 - visit_typed_expr_fn(self, location, type_, kind, args, body, return_annotation); 172 + visit_typed_expr_fn( 173 + self, 174 + location, 175 + type_, 176 + kind, 177 + arguments, 178 + body, 179 + return_annotation, 180 + ); 173 181 } 174 182 175 183 fn visit_typed_expr_list( ··· 187 195 location: &'ast SrcSpan, 188 196 type_: &'ast Arc<Type>, 189 197 fun: &'ast TypedExpr, 190 - args: &'ast [TypedCallArg], 198 + arguments: &'ast [TypedCallArg], 191 199 ) { 192 - visit_typed_expr_call(self, location, type_, fun, args); 200 + visit_typed_expr_call(self, location, type_, fun, arguments); 193 201 } 194 202 195 203 fn visit_typed_expr_bin_op( ··· 303 311 type_: &'ast Arc<Type>, 304 312 record: &'ast Option<Box<TypedAssignment>>, 305 313 constructor: &'ast TypedExpr, 306 - args: &'ast [TypedCallArg], 314 + arguments: &'ast [TypedCallArg], 307 315 ) { 308 - visit_typed_expr_record_update(self, location, type_, record, constructor, args); 316 + visit_typed_expr_record_update(self, location, type_, record, constructor, arguments); 309 317 } 310 318 311 319 fn visit_typed_expr_negate_bool(&mut self, location: &'ast SrcSpan, value: &'ast TypedExpr) { ··· 766 774 location, 767 775 type_, 768 776 kind, 769 - args, 777 + arguments, 770 778 body, 771 779 return_annotation, 772 780 purity: _, 773 - } => v.visit_typed_expr_fn(location, type_, kind, args, body, return_annotation), 781 + } => v.visit_typed_expr_fn(location, type_, kind, arguments, body, return_annotation), 774 782 TypedExpr::List { 775 783 location, 776 784 type_, ··· 781 789 location, 782 790 type_, 783 791 fun, 784 - args, 785 - } => v.visit_typed_expr_call(location, type_, fun, args), 792 + arguments, 793 + } => v.visit_typed_expr_call(location, type_, fun, arguments), 786 794 TypedExpr::BinOp { 787 795 location, 788 796 type_, ··· 855 863 type_, 856 864 record_assignment, 857 865 constructor, 858 - args, 859 - } => { 860 - v.visit_typed_expr_record_update(location, type_, record_assignment, constructor, args) 861 - } 866 + arguments, 867 + } => v.visit_typed_expr_record_update( 868 + location, 869 + type_, 870 + record_assignment, 871 + constructor, 872 + arguments, 873 + ), 862 874 TypedExpr::NegateBool { location, value } => { 863 875 v.visit_typed_expr_negate_bool(location, value) 864 876 } ··· 956 968 _location: &'a SrcSpan, 957 969 _type_: &'a Arc<Type>, 958 970 _kind: &'a FunctionLiteralKind, 959 - _args: &'a [TypedArg], 971 + _arguments: &'a [TypedArg], 960 972 body: &'a Vec1<TypedStatement>, 961 973 _return_annotation: &'a Option<TypeAst>, 962 974 ) where ··· 990 1002 _location: &'a SrcSpan, 991 1003 _type_: &'a Arc<Type>, 992 1004 fun: &'a TypedExpr, 993 - args: &'a [TypedCallArg], 1005 + arguments: &'a [TypedCallArg], 994 1006 ) where 995 1007 V: Visit<'a> + ?Sized, 996 1008 { 997 1009 v.visit_typed_expr(fun); 998 - for arg in args { 999 - v.visit_typed_call_arg(arg); 1010 + for argument in arguments { 1011 + v.visit_typed_call_arg(argument); 1000 1012 } 1001 1013 } 1002 1014 ··· 1152 1164 _type: &'a Arc<Type>, 1153 1165 record: &'a Option<Box<TypedAssignment>>, 1154 1166 constructor: &'a TypedExpr, 1155 - args: &'a [TypedCallArg], 1167 + arguments: &'a [TypedCallArg], 1156 1168 ) where 1157 1169 V: Visit<'a> + ?Sized, 1158 1170 { ··· 1160 1172 if let Some(record) = record { 1161 1173 v.visit_typed_assignment(record); 1162 1174 } 1163 - for arg in args { 1164 - v.visit_typed_call_arg(arg); 1175 + for argument in arguments { 1176 + v.visit_typed_call_arg(argument); 1165 1177 } 1166 1178 } 1167 1179
+10 -10
compiler-core/src/ast_folder.rs
··· 957 957 location, 958 958 module, 959 959 name, 960 - args, 960 + arguments, 961 961 tag: (), 962 962 type_: (), 963 963 field_map: _, 964 964 record_constructor: _, 965 - } => self.fold_constant_record(location, module, name, args), 965 + } => self.fold_constant_record(location, module, name, arguments), 966 966 967 967 Constant::BitArray { location, segments } => { 968 968 self.fold_constant_bit_array(location, segments) ··· 1035 1035 location: SrcSpan, 1036 1036 module: Option<(EcoString, SrcSpan)>, 1037 1037 name: EcoString, 1038 - args: Vec<CallArg<UntypedConstant>>, 1038 + arguments: Vec<CallArg<UntypedConstant>>, 1039 1039 ) -> UntypedConstant { 1040 1040 Constant::Record { 1041 1041 location, 1042 1042 module, 1043 1043 name, 1044 - args, 1044 + arguments, 1045 1045 tag: (), 1046 1046 type_: (), 1047 1047 field_map: None, ··· 1122 1122 location, 1123 1123 module, 1124 1124 name, 1125 - args, 1125 + arguments, 1126 1126 tag, 1127 1127 type_, 1128 1128 field_map, 1129 1129 record_constructor, 1130 1130 } => { 1131 - let args = args 1131 + let arguments = arguments 1132 1132 .into_iter() 1133 - .map(|mut arg| { 1134 - arg.value = self.fold_constant(arg.value); 1135 - arg 1133 + .map(|mut argument| { 1134 + argument.value = self.fold_constant(argument.value); 1135 + argument 1136 1136 }) 1137 1137 .collect(); 1138 1138 Constant::Record { 1139 1139 location, 1140 1140 module, 1141 1141 name, 1142 - args, 1142 + arguments, 1143 1143 tag, 1144 1144 type_, 1145 1145 field_map,
+8 -5
compiler-core/src/build.rs
··· 490 490 // `Wobble`. 491 491 // 492 492 Type::Named { 493 - module, name, args, .. 493 + module, 494 + name, 495 + arguments, 496 + .. 494 497 } => { 495 498 let Some(module) = importable_modules.get(module) else { 496 499 return vec![]; ··· 504 507 module: Some(module.name.clone()), 505 508 span: type_.origin, 506 509 }]; 507 - for arg in args { 510 + for argument in arguments { 508 511 locations.extend(type_to_definition_locations( 509 - arg.clone(), 512 + argument.clone(), 510 513 importable_modules, 511 514 )); 512 515 } ··· 516 519 // For fn types we just get the locations of their arguments and return 517 520 // type. 518 521 // 519 - Type::Fn { args, return_ } => args 522 + Type::Fn { arguments, return_ } => arguments 520 523 .iter() 521 - .flat_map(|arg| type_to_definition_locations(arg.clone(), importable_modules)) 524 + .flat_map(|argument| type_to_definition_locations(argument.clone(), importable_modules)) 522 525 .chain(type_to_definition_locations( 523 526 return_.clone(), 524 527 importable_modules,
+3 -3
compiler-core/src/call_graph.rs
··· 487 487 } 488 488 } 489 489 490 - Constant::Record { args, .. } => { 491 - for arg in args { 492 - self.constant(&arg.value); 490 + Constant::Record { arguments, .. } => { 491 + for argument in arguments { 492 + self.constant(&argument.value); 493 493 } 494 494 } 495 495
+11 -11
compiler-core/src/docs/printer.rs
··· 393 393 package, 394 394 module, 395 395 name, 396 - args, 396 + arguments, 397 397 publicity, 398 398 .. 399 399 } => { 400 400 let name = self.named_type_name(publicity, package, module, name); 401 - if args.is_empty() { 401 + if arguments.is_empty() { 402 402 name 403 403 } else { 404 404 name.append(Self::type_arguments( 405 - args.iter().map(|argument| self.type_(argument)), 405 + arguments.iter().map(|argument| self.type_(argument)), 406 406 )) 407 407 } 408 408 } 409 - Type::Fn { args, return_ } => docvec![ 409 + Type::Fn { arguments, return_ } => docvec![ 410 410 self.keyword("fn"), 411 - Self::type_arguments(args.iter().map(|argument| self.type_(argument))), 411 + Self::type_arguments(arguments.iter().map(|argument| self.type_(argument))), 412 412 " -> ", 413 413 self.type_(return_) 414 414 ], ··· 585 585 /// 586 586 fn register_local_type_variable_names(&mut self, type_: &Type) { 587 587 match type_ { 588 - Type::Named { args, .. } => { 589 - for arg in args { 590 - self.register_local_type_variable_names(arg); 588 + Type::Named { arguments, .. } => { 589 + for argument in arguments { 590 + self.register_local_type_variable_names(argument); 591 591 } 592 592 } 593 - Type::Fn { args, return_ } => { 594 - for arg in args { 595 - self.register_local_type_variable_names(arg); 593 + Type::Fn { arguments, return_ } => { 594 + for argument in arguments { 595 + self.register_local_type_variable_names(argument); 596 596 } 597 597 self.register_local_type_variable_names(return_); 598 598 }
+127 -93
compiler-core/src/erlang.rs
··· 314 314 Definition::Function(Function { 315 315 publicity, 316 316 name: Some((_, name)), 317 - arguments: args, 317 + arguments, 318 318 implementations, 319 319 .. 320 320 }) if publicity.is_importable() || overridden_publicity.contains(name) => { ··· 324 324 exports.push( 325 325 atom_string(function_name.into()) 326 326 .append("/") 327 - .append(args.len()), 327 + .append(arguments.len()), 328 328 ) 329 329 } 330 330 } ··· 385 385 name 386 386 } else { 387 387 let type_printer = TypePrinter::new(module_name); 388 - let args = constructor 388 + let arguments = constructor 389 389 .arguments 390 390 .iter() 391 391 .map(|argument| type_printer.print(&argument.type_)); 392 - tuple(std::iter::once(name).chain(args)) 392 + tuple(std::iter::once(name).chain(arguments)) 393 393 } 394 394 }) 395 395 .chain(phantom_vars_constructor); ··· 481 481 std::iter::once(&function.return_type).chain(function.arguments.iter().map(|a| &a.type_)), 482 482 ); 483 483 let type_printer = TypePrinter::new(module).with_var_usages(&var_usages); 484 - let args_spec = function 484 + let arguments_spec = function 485 485 .arguments 486 486 .iter() 487 487 .map(|a| type_printer.print(&a.type_)); 488 488 let return_spec = type_printer.print(&function.return_type); 489 489 490 - let spec = fun_spec(function_name, args_spec, return_spec); 490 + let spec = fun_spec(function_name, arguments_spec, return_spec); 491 491 let arguments = if function.external_erlang.is_some() { 492 - external_fun_args(&function.arguments, &mut env) 492 + external_fun_arguments(&function.arguments, &mut env) 493 493 } else { 494 - fun_args(&function.arguments, &mut env) 494 + fun_arguments(&function.arguments, &mut env) 495 495 }; 496 496 497 497 let body = function ··· 606 606 } 607 607 } 608 608 609 - fn external_fun_args<'a>(args: &'a [TypedArg], env: &mut Env<'a>) -> Document<'a> { 610 - wrap_args(args.iter().map(|a| { 611 - let name = match &a.names { 609 + fn external_fun_arguments<'a>(arguments: &'a [TypedArg], env: &mut Env<'a>) -> Document<'a> { 610 + wrap_arguments(arguments.iter().map(|argument| { 611 + let name = match &argument.names { 612 612 ArgNames::Discard { name, .. } 613 613 | ArgNames::LabelledDiscard { name, .. } 614 614 | ArgNames::Named { name, .. } ··· 622 622 })) 623 623 } 624 624 625 - fn fun_args<'a>(args: &'a [TypedArg], env: &mut Env<'a>) -> Document<'a> { 626 - wrap_args(args.iter().map(|a| match &a.names { 625 + fn fun_arguments<'a>(arguments: &'a [TypedArg], env: &mut Env<'a>) -> Document<'a> { 626 + wrap_arguments(arguments.iter().map(|argument| match &argument.names { 627 627 ArgNames::Discard { .. } | ArgNames::LabelledDiscard { .. } => "_".to_doc(), 628 628 ArgNames::Named { name, .. } | ArgNames::NamedLabelled { name, .. } => { 629 629 env.next_local_var_name(name) ··· 631 631 })) 632 632 } 633 633 634 - fn wrap_args<'a, I>(args: I) -> Document<'a> 634 + fn wrap_arguments<'a, I>(arguments: I) -> Document<'a> 635 635 where 636 636 I: IntoIterator<Item = Document<'a>>, 637 637 { 638 638 break_("", "") 639 - .append(join(args, break_(",", ", "))) 639 + .append(join(arguments, break_(",", ", "))) 640 640 .nest(INDENT) 641 641 .append(break_("", "")) 642 642 .surround("(", ")") ··· 645 645 646 646 fn fun_spec<'a>( 647 647 name: &'a str, 648 - args: impl IntoIterator<Item = Document<'a>>, 648 + arguments: impl IntoIterator<Item = Document<'a>>, 649 649 return_: Document<'a>, 650 650 ) -> Document<'a> { 651 651 "-spec " 652 652 .to_doc() 653 653 .append(atom(name)) 654 - .append(wrap_args(args)) 654 + .append(wrap_arguments(arguments)) 655 655 .append(" -> ") 656 656 .append(return_) 657 657 .append(".") ··· 1385 1385 ValueConstructorVariant::Record { 1386 1386 name: record_name, .. 1387 1387 } => match constructor.type_.deref() { 1388 - Type::Fn { args, .. } => { 1389 - let chars = incrementing_args_list(args.len()); 1388 + Type::Fn { arguments, .. } => { 1389 + let chars = incrementing_arguments_list(arguments.len()); 1390 1390 "fun(" 1391 1391 .to_doc() 1392 1392 .append(chars.clone()) ··· 1476 1476 ), 1477 1477 1478 1478 Constant::Record { 1479 - tag, type_, args, .. 1480 - } if args.is_empty() => match type_.deref() { 1481 - Type::Fn { args, .. } => record_constructor_function(tag, args.len()), 1479 + tag, 1480 + type_, 1481 + arguments, 1482 + .. 1483 + } if arguments.is_empty() => match type_.deref() { 1484 + Type::Fn { arguments, .. } => record_constructor_function(tag, arguments.len()), 1482 1485 _ => atom_string(to_snake_case(tag)), 1483 1486 }, 1484 1487 1485 - Constant::Record { tag, args, .. } => { 1486 - let args = args.iter().map(|a| const_inline(&a.value, env)); 1488 + Constant::Record { tag, arguments, .. } => { 1489 + let arguments = arguments 1490 + .iter() 1491 + .map(|argument| const_inline(&argument.value, env)); 1487 1492 let tag = atom_string(to_snake_case(tag)); 1488 - tuple(std::iter::once(tag).chain(args)) 1493 + tuple(std::iter::once(tag).chain(arguments)) 1489 1494 } 1490 1495 1491 1496 Constant::Var { ··· 1507 1512 } 1508 1513 1509 1514 fn record_constructor_function(tag: &EcoString, arity: usize) -> Document<'_> { 1510 - let chars = incrementing_args_list(arity); 1515 + let chars = incrementing_arguments_list(arity); 1511 1516 "fun(" 1512 1517 .to_doc() 1513 1518 .append(chars.clone()) ··· 1715 1720 let tuple_doc = bare_clause_guard(tuple, env); 1716 1721 "erlang:element" 1717 1722 .to_doc() 1718 - .append(wrap_args([index_doc, tuple_doc])) 1723 + .append(wrap_arguments([index_doc, tuple_doc])) 1719 1724 } 1720 1725 1721 1726 fn clause_guard<'a>(guard: &'a TypedClauseGuard, env: &mut Env<'a>) -> Document<'a> { ··· 1791 1796 .group() 1792 1797 } 1793 1798 1794 - fn call<'a>(fun: &'a TypedExpr, args: &'a [TypedCallArg], env: &mut Env<'a>) -> Document<'a> { 1795 - docs_args_call( 1799 + fn call<'a>(fun: &'a TypedExpr, arguments: &'a [TypedCallArg], env: &mut Env<'a>) -> Document<'a> { 1800 + docs_arguments_call( 1796 1801 fun, 1797 - args.iter() 1798 - .map(|arg| maybe_block_expr(&arg.value, env)) 1802 + arguments 1803 + .iter() 1804 + .map(|argument| maybe_block_expr(&argument.value, env)) 1799 1805 .collect(), 1800 1806 env, 1801 1807 ) 1802 1808 } 1803 1809 1804 - fn module_fn_with_args<'a>( 1810 + fn module_fn_with_arguments<'a>( 1805 1811 module: &'a str, 1806 1812 name: &'a str, 1807 - args: Vec<Document<'a>>, 1813 + arguments: Vec<Document<'a>>, 1808 1814 env: &Env<'a>, 1809 1815 ) -> Document<'a> { 1810 1816 let name = escape_erlang_existing_name(name); 1811 - let args = wrap_args(args); 1817 + let arguments = wrap_arguments(arguments); 1812 1818 if module == env.module { 1813 - atom(name).append(args) 1819 + atom(name).append(arguments) 1814 1820 } else { 1815 1821 atom_string(module.replace('/', "@").into()) 1816 1822 .append(":") 1817 1823 .append(atom(name)) 1818 - .append(args) 1824 + .append(arguments) 1819 1825 } 1820 1826 } 1821 1827 1822 - fn docs_args_call<'a>( 1828 + fn docs_arguments_call<'a>( 1823 1829 fun: &'a TypedExpr, 1824 - mut args: Vec<Document<'a>>, 1830 + mut arguments: Vec<Document<'a>>, 1825 1831 env: &mut Env<'a>, 1826 1832 ) -> Document<'a> { 1827 1833 match fun { ··· 1836 1842 .. 1837 1843 }, 1838 1844 .. 1839 - } => tuple(std::iter::once(atom_string(to_snake_case(name))).chain(args)), 1845 + } => tuple(std::iter::once(atom_string(to_snake_case(name))).chain(arguments)), 1840 1846 1841 1847 TypedExpr::Var { 1842 1848 constructor: ··· 1850 1856 .. 1851 1857 }, 1852 1858 .. 1853 - } => module_fn_with_args(module, name, args, env), 1859 + } => module_fn_with_arguments(module, name, arguments, env), 1854 1860 1855 1861 // Match against a Constant::Var that contains a function. 1856 1862 // We want this to be emitted like a normal function call, not a function variable ··· 1876 1882 .. 1877 1883 } 1878 1884 | ValueConstructorVariant::ModuleFn { module, name, .. } => { 1879 - module_fn_with_args(module, name, args, env) 1885 + module_fn_with_arguments(module, name, arguments, env) 1880 1886 } 1881 1887 _ => { 1882 1888 unreachable!("The above clause guard ensures that this is a module fn") ··· 1892 1898 | ModuleValueConstructor::Fn { module, name, .. }, 1893 1899 .. 1894 1900 } => { 1895 - let args = wrap_args(args); 1901 + let arguments = wrap_arguments(arguments); 1896 1902 let name = escape_erlang_existing_name(name); 1897 1903 // We use the constructor Fn variant's `module` and function `name`. 1898 1904 // It would also be valid to use the module and label as in the ··· 1905 1911 atom_string(module_erlang_name(module)) 1906 1912 .append(":") 1907 1913 .append(atom_string(name.into())) 1908 - .append(args) 1914 + .append(arguments) 1909 1915 } 1910 1916 1911 1917 TypedExpr::Fn { kind, body, .. } if kind.is_capture() => { 1912 1918 if let Statement::Expression(TypedExpr::Call { 1913 1919 fun, 1914 - args: inner_args, 1920 + arguments: inner_arguments, 1915 1921 .. 1916 1922 }) = body.first() 1917 1923 { 1918 - let mut merged_args = Vec::with_capacity(inner_args.len()); 1919 - for arg in inner_args { 1924 + let mut merged_arguments = Vec::with_capacity(inner_arguments.len()); 1925 + for arg in inner_arguments { 1920 1926 match &arg.value { 1921 1927 TypedExpr::Var { name, .. } if name == CAPTURE_VARIABLE => { 1922 - merged_args.push(args.swap_remove(0)) 1928 + merged_arguments.push(arguments.swap_remove(0)) 1923 1929 } 1924 - e => merged_args.push(maybe_block_expr(e, env)), 1930 + e => merged_arguments.push(maybe_block_expr(e, env)), 1925 1931 } 1926 1932 } 1927 - docs_args_call(fun, merged_args, env) 1933 + docs_arguments_call(fun, merged_arguments, env) 1928 1934 } else { 1929 1935 panic!("Erl printing: Capture was not a call") 1930 1936 } ··· 1936 1942 | TypedExpr::Panic { .. } 1937 1943 | TypedExpr::RecordAccess { .. } 1938 1944 | TypedExpr::TupleIndex { .. } => { 1939 - let args = wrap_args(args); 1940 - expr(fun, env).surround("(", ")").append(args) 1945 + let arguments = wrap_arguments(arguments); 1946 + expr(fun, env).surround("(", ")").append(arguments) 1941 1947 } 1942 1948 1943 1949 other => { 1944 - let args = wrap_args(args); 1945 - maybe_block_expr(other, env).append(args) 1950 + let arguments = wrap_arguments(arguments); 1951 + maybe_block_expr(other, env).append(arguments) 1946 1952 } 1947 1953 } 1948 1954 } ··· 1950 1956 fn record_update<'a>( 1951 1957 record: &'a Option<Box<TypedAssignment>>, 1952 1958 constructor: &'a TypedExpr, 1953 - args: &'a [TypedCallArg], 1959 + arguments: &'a [TypedCallArg], 1954 1960 env: &mut Env<'a>, 1955 1961 ) -> Document<'a> { 1956 1962 let vars = env.current_scope_vars.clone(); ··· 1960 1966 assignment(record, env, Position::NotTail), 1961 1967 ",", 1962 1968 line(), 1963 - call(constructor, args, env) 1969 + call(constructor, arguments, env) 1964 1970 ], 1965 - None => call(constructor, args, env), 1971 + None => call(constructor, arguments, env), 1966 1972 }; 1967 1973 1968 1974 env.current_scope_vars = vars; ··· 2046 2052 .map(|message| maybe_block_expr(message, env)) 2047 2053 .unwrap_or("nil".to_doc()); 2048 2054 2049 - "echo".to_doc().append(wrap_args(vec![ 2055 + "echo".to_doc().append(wrap_arguments(vec![ 2050 2056 body, 2051 2057 message, 2052 2058 env.line_numbers.line_number(location.start).to_doc(), ··· 2091 2097 .append(value); 2092 2098 } 2093 2099 let error = docvec!["#{", fields_doc.group().nest(INDENT), "}"]; 2094 - docvec!["erlang:error", wrap_args([error.group()])] 2100 + docvec!["erlang:error", wrap_arguments([error.group()])] 2095 2101 } 2096 2102 2097 2103 fn expr<'a>(expression: &'a TypedExpr, env: &mut Env<'a>) -> Document<'a> { ··· 2138 2144 name, constructor, .. 2139 2145 } => var(name, constructor, env), 2140 2146 2141 - TypedExpr::Fn { args, body, .. } => fun(args, body, env), 2147 + TypedExpr::Fn { 2148 + arguments, body, .. 2149 + } => fun(arguments, body, env), 2142 2150 2143 2151 TypedExpr::NegateBool { value, .. } => negate_with("not ", value, env), 2144 2152 ··· 2146 2154 2147 2155 TypedExpr::List { elements, tail, .. } => expr_list(elements, tail, env), 2148 2156 2149 - TypedExpr::Call { fun, args, .. } => call(fun, args, env), 2157 + TypedExpr::Call { fun, arguments, .. } => call(fun, arguments, env), 2150 2158 2151 2159 TypedExpr::ModuleSelect { 2152 2160 constructor: ModuleValueConstructor::Record { name, arity: 0, .. }, ··· 2179 2187 TypedExpr::RecordUpdate { 2180 2188 record_assignment, 2181 2189 constructor, 2182 - args, 2190 + arguments, 2183 2191 .. 2184 - } => record_update(record_assignment, constructor, args, env), 2192 + } => record_update(record_assignment, constructor, arguments, env), 2185 2193 2186 2194 TypedExpr::Case { 2187 2195 subjects, clauses, .. ··· 2312 2320 let mut assignments = Vec::new(); 2313 2321 2314 2322 let (subject, mut fields) = match value { 2315 - TypedExpr::Call { fun, args, .. } => assert_call(fun, args, &mut assignments, env), 2323 + TypedExpr::Call { fun, arguments, .. } => { 2324 + assert_call(fun, arguments, &mut assignments, env) 2325 + } 2316 2326 TypedExpr::BinOp { 2317 2327 name, left, right, .. 2318 2328 } => { ··· 2437 2447 .surround("[", "]"); 2438 2448 2439 2449 ( 2440 - docs_args_call(function, argument_variables, env), 2450 + docs_arguments_call(function, argument_variables, env), 2441 2451 vec![("kind", atom("function_call")), ("arguments", arguments)], 2442 2452 ) 2443 2453 } ··· 2697 2707 let tuple_doc = maybe_block_expr(tuple, env); 2698 2708 "erlang:element" 2699 2709 .to_doc() 2700 - .append(wrap_args([index_doc, tuple_doc])) 2710 + .append(wrap_arguments([index_doc, tuple_doc])) 2701 2711 } 2702 2712 2703 2713 fn module_select_fn<'a>(type_: Arc<Type>, module_name: &'a str, label: &'a str) -> Document<'a> { 2704 2714 match crate::type_::collapse_links(type_).as_ref() { 2705 - Type::Fn { args, .. } => function_reference(Some(module_name), label, args.len()), 2715 + Type::Fn { arguments, .. } => function_reference(Some(module_name), label, arguments.len()), 2706 2716 2707 2717 _ => module_name_atom(module_name) 2708 2718 .append(":") ··· 2711 2721 } 2712 2722 } 2713 2723 2714 - fn fun<'a>(args: &'a [TypedArg], body: &'a [TypedStatement], env: &mut Env<'a>) -> Document<'a> { 2724 + fn fun<'a>( 2725 + arguments: &'a [TypedArg], 2726 + body: &'a [TypedStatement], 2727 + env: &mut Env<'a>, 2728 + ) -> Document<'a> { 2715 2729 let current_scope_vars = env.current_scope_vars.clone(); 2716 2730 let doc = "fun" 2717 2731 .to_doc() 2718 - .append(fun_args(args, env).append(" ->")) 2732 + .append(fun_arguments(arguments, env).append(" ->")) 2719 2733 .append( 2720 2734 break_("", " ") 2721 2735 .append(statement_sequence(body, env)) ··· 2728 2742 doc 2729 2743 } 2730 2744 2731 - fn incrementing_args_list(arity: usize) -> EcoString { 2745 + fn incrementing_arguments_list(arity: usize) -> EcoString { 2732 2746 let arguments = (0..arity).map(|c| format!("Field@{c}")); 2733 2747 Itertools::intersperse(arguments, ", ".into()) 2734 2748 .collect::<String>() ··· 2935 2949 TypeVar::Link { type_ } => type_var_ids(type_, ids), 2936 2950 }, 2937 2951 Type::Named { 2938 - args, module, name, .. 2939 - } => match args[..] { 2952 + arguments, 2953 + module, 2954 + name, 2955 + .. 2956 + } => match arguments[..] { 2940 2957 [ref arg_ok, ref arg_err] if is_prelude_module(module) && name == "Result" => { 2941 2958 result_type_var_ids(ids, arg_ok, arg_err) 2942 2959 } 2943 2960 _ => { 2944 - for arg in args { 2945 - type_var_ids(arg, ids) 2961 + for argument in arguments { 2962 + type_var_ids(argument, ids) 2946 2963 } 2947 2964 } 2948 2965 }, 2949 - Type::Fn { args, return_ } => { 2950 - for arg in args { 2951 - type_var_ids(arg, ids) 2966 + Type::Fn { arguments, return_ } => { 2967 + for argument in arguments { 2968 + type_var_ids(argument, ids) 2952 2969 } 2953 2970 type_var_ids(return_, ids); 2954 2971 } ··· 3035 3052 Type::Var { type_ } => self.print_var(&type_.borrow()), 3036 3053 3037 3054 Type::Named { 3038 - name, module, args, .. 3039 - } if is_prelude_module(module) => self.print_prelude_type(name, args), 3055 + name, 3056 + module, 3057 + arguments, 3058 + .. 3059 + } if is_prelude_module(module) => self.print_prelude_type(name, arguments), 3040 3060 3041 3061 Type::Named { 3042 - name, module, args, .. 3043 - } => self.print_type_app(module, name, args), 3062 + name, 3063 + module, 3064 + arguments, 3065 + .. 3066 + } => self.print_type_app(module, name, arguments), 3044 3067 3045 - Type::Fn { args, return_ } => self.print_fn(args, return_), 3068 + Type::Fn { arguments, return_ } => self.print_fn(arguments, return_), 3046 3069 3047 3070 Type::Tuple { elements } => tuple(elements.iter().map(|element| self.print(element))), 3048 3071 } ··· 3065 3088 } 3066 3089 } 3067 3090 3068 - fn print_prelude_type(&self, name: &str, args: &[Arc<Type>]) -> Document<'static> { 3091 + fn print_prelude_type(&self, name: &str, arguments: &[Arc<Type>]) -> Document<'static> { 3069 3092 match name { 3070 3093 "Nil" => "nil".to_doc(), 3071 3094 "Int" | "UtfCodepoint" => "integer()".to_doc(), ··· 3074 3097 "Float" => "float()".to_doc(), 3075 3098 "BitArray" => "bitstring()".to_doc(), 3076 3099 "List" => { 3077 - let arg0 = self.print(args.first().expect("print_prelude_type list")); 3100 + let arg0 = self.print(arguments.first().expect("print_prelude_type list")); 3078 3101 "list(".to_doc().append(arg0).append(")") 3079 3102 } 3080 - "Result" => match args { 3103 + "Result" => match arguments { 3081 3104 [arg_ok, arg_err] => { 3082 3105 let ok = tuple(["ok".to_doc(), self.print(arg_ok)]); 3083 3106 let error = tuple(["error".to_doc(), self.print(arg_err)]); ··· 3091 3114 } 3092 3115 } 3093 3116 3094 - fn print_type_app(&self, module: &str, name: &str, args: &[Arc<Type>]) -> Document<'static> { 3095 - let args = join(args.iter().map(|a| self.print(a)), ", ".to_doc()); 3117 + fn print_type_app( 3118 + &self, 3119 + module: &str, 3120 + name: &str, 3121 + arguments: &[Arc<Type>], 3122 + ) -> Document<'static> { 3123 + let arguments = join( 3124 + arguments.iter().map(|argument| self.print(argument)), 3125 + ", ".to_doc(), 3126 + ); 3096 3127 let name = erl_safe_type_name(to_snake_case(name)).to_doc(); 3097 3128 if self.current_module == module { 3098 - docvec![name, "(", args, ")"] 3129 + docvec![name, "(", arguments, ")"] 3099 3130 } else { 3100 - docvec![module_name_atom(module), ":", name, "(", args, ")"] 3131 + docvec![module_name_atom(module), ":", name, "(", arguments, ")"] 3101 3132 } 3102 3133 } 3103 3134 3104 - fn print_fn(&self, args: &[Arc<Type>], return_: &Type) -> Document<'static> { 3105 - let args = join(args.iter().map(|a| self.print(a)), ", ".to_doc()); 3135 + fn print_fn(&self, arguments: &[Arc<Type>], return_: &Type) -> Document<'static> { 3136 + let arguments = join( 3137 + arguments.iter().map(|argument| self.print(argument)), 3138 + ", ".to_doc(), 3139 + ); 3106 3140 let return_ = self.print(return_); 3107 3141 "fun((" 3108 3142 .to_doc() 3109 - .append(args) 3143 + .append(arguments) 3110 3144 .append(") -> ") 3111 3145 .append(return_) 3112 3146 .append(")") ··· 3156 3190 } 3157 3191 } 3158 3192 3159 - TypedConstant::Record { args, .. } => args 3193 + TypedConstant::Record { arguments, .. } => arguments 3160 3194 .iter() 3161 - .for_each(|arg| find_referenced_private_functions(&arg.value, already_found)), 3195 + .for_each(|argument| find_referenced_private_functions(&argument.value, already_found)), 3162 3196 3163 3197 TypedConstant::StringConcatenation { left, right, .. } => { 3164 3198 find_referenced_private_functions(left, already_found);
+5 -5
compiler-core/src/erlang/pattern.rs
··· 56 56 Pattern::String { value, .. } => string(value), 57 57 58 58 Pattern::Constructor { 59 - arguments: args, 59 + arguments, 60 60 constructor: Inferred::Known(PatternConstructor { name, .. }), 61 61 .. 62 - } => tag_tuple_pattern(name, args, vars, env, guards), 62 + } => tag_tuple_pattern(name, arguments, vars, env, guards), 63 63 64 64 Pattern::Constructor { 65 65 constructor: Inferred::Unknown, ··· 229 229 230 230 fn tag_tuple_pattern<'a>( 231 231 name: &'a str, 232 - args: &'a [CallArg<TypedPattern>], 232 + arguments: &'a [CallArg<TypedPattern>], 233 233 vars: &mut Vec<&'a str>, 234 234 env: &mut Env<'a>, 235 235 guards: &mut Vec<Document<'a>>, 236 236 ) -> Document<'a> { 237 - if args.is_empty() { 237 + if arguments.is_empty() { 238 238 atom_string(to_snake_case(name)) 239 239 } else { 240 240 tuple( 241 241 [atom_string(to_snake_case(name))] 242 242 .into_iter() 243 - .chain(args.iter().map(|p| print(&p.value, vars, env, guards))), 243 + .chain(arguments.iter().map(|p| print(&p.value, vars, env, guards))), 244 244 ) 245 245 } 246 246 }
+1 -1
compiler-core/src/erlang/tests/records.rs
··· 52 52 package: "package".into(), 53 53 module: module_name, 54 54 name: "my_type".into(), 55 - args: vec![], 55 + arguments: vec![], 56 56 inferred_variant: None, 57 57 }) 58 58 )]
+2 -2
compiler-core/src/error.rs
··· 2053 2053 // Remap the pipe function type into just the type expected by the pipe. 2054 2054 let expected = expected 2055 2055 .fn_types() 2056 - .and_then(|(args, _)| args.first().cloned()); 2056 + .and_then(|(arguments, _)| arguments.first().cloned()); 2057 2057 2058 2058 // Remap the argument as well, if it's a function. 2059 2059 let given = given 2060 2060 .fn_types() 2061 - .and_then(|(args, _)| args.first().cloned()) 2061 + .and_then(|(arguments, _)| arguments.first().cloned()) 2062 2062 .unwrap_or_else(|| given.clone()); 2063 2063 2064 2064 let mut printer = Printer::new(names);
+17 -8
compiler-core/src/exhaustiveness.rs
··· 779 779 } 780 780 781 781 Type::Named { 782 - module, name, args, .. 782 + module, 783 + name, 784 + arguments, 785 + .. 783 786 } if is_prelude_module(module) && name == "List" => BranchMode::List { 784 - inner_type: args.first().expect("list has a type argument").clone(), 787 + inner_type: arguments.first().expect("list has a type argument").clone(), 785 788 }, 786 789 787 790 Type::Tuple { elements } => BranchMode::Tuple { ··· 791 794 Type::Named { 792 795 module, 793 796 name, 794 - args, 797 + arguments, 795 798 inferred_variant, 796 799 .. 797 800 } => { 798 801 let constructors = ConstructorSpecialiser::specialise_constructors( 799 802 env.get_constructors_for_type(module, name) 800 803 .expect("Custom type variants must exist"), 801 - args.as_slice(), 804 + arguments.as_slice(), 802 805 &env.current_module, 803 806 module, 804 807 ); ··· 2638 2641 package, 2639 2642 module, 2640 2643 name, 2641 - args, 2644 + arguments, 2642 2645 inferred_variant, 2643 2646 } => Type::Named { 2644 2647 publicity: *publicity, 2645 2648 package: package.clone(), 2646 2649 module: module.clone(), 2647 2650 name: name.clone(), 2648 - args: args.iter().map(|a| self.specialise_type(a)).collect(), 2651 + arguments: arguments 2652 + .iter() 2653 + .map(|argument| self.specialise_type(argument)) 2654 + .collect(), 2649 2655 inferred_variant: *inferred_variant, 2650 2656 }, 2651 2657 2652 - Type::Fn { args, return_ } => Type::Fn { 2653 - args: args.iter().map(|a| self.specialise_type(a)).collect(), 2658 + Type::Fn { arguments, return_ } => Type::Fn { 2659 + arguments: arguments 2660 + .iter() 2661 + .map(|argument| self.specialise_type(argument)) 2662 + .collect(), 2654 2663 return_: return_.clone(), 2655 2664 }, 2656 2665
+126 -92
compiler-core/src/format.rs
··· 367 367 368 368 Definition::TypeAlias(TypeAlias { 369 369 alias, 370 - parameters: args, 370 + parameters: arguments, 371 371 type_ast: resolved_type, 372 372 publicity, 373 373 deprecation, ··· 376 376 }) => self.type_alias( 377 377 *publicity, 378 378 alias, 379 - args, 379 + arguments, 380 380 resolved_type, 381 381 deprecation, 382 382 location, ··· 492 492 493 493 Constant::Record { 494 494 name, 495 - args, 495 + arguments, 496 496 module: None, 497 497 .. 498 - } if args.is_empty() => name.to_doc(), 498 + } if arguments.is_empty() => name.to_doc(), 499 499 500 500 Constant::Record { 501 501 name, 502 - args, 502 + arguments, 503 503 module: Some((m, _)), 504 504 .. 505 - } if args.is_empty() => m.to_doc().append(".").append(name.as_str()), 505 + } if arguments.is_empty() => m.to_doc().append(".").append(name.as_str()), 506 506 507 507 Constant::Record { 508 508 name, 509 - args, 509 + arguments, 510 510 module: None, 511 511 location, 512 512 .. 513 513 } => { 514 - let args = args.iter().map(|a| self.constant_call_arg(a)).collect_vec(); 514 + let arguments = arguments 515 + .iter() 516 + .map(|argument| self.constant_call_arg(argument)) 517 + .collect_vec(); 515 518 name.to_doc() 516 - .append(self.wrap_args(args, location.end)) 519 + .append(self.wrap_arguments(arguments, location.end)) 517 520 .group() 518 521 } 519 522 520 523 Constant::Record { 521 524 name, 522 - args, 525 + arguments, 523 526 module: Some((m, _)), 524 527 location, 525 528 .. 526 529 } => { 527 - let args = args.iter().map(|a| self.constant_call_arg(a)).collect_vec(); 530 + let arguments = arguments 531 + .iter() 532 + .map(|argument| self.constant_call_arg(argument)) 533 + .collect_vec(); 528 534 m.to_doc() 529 535 .append(".") 530 536 .append(name.as_str()) 531 - .append(self.wrap_args(args, location.end)) 537 + .append(self.wrap_arguments(arguments, location.end)) 532 538 .group() 533 539 } 534 540 ··· 668 674 }; 669 675 } 670 676 671 - let args_docs = elements.iter().map(|element| self.const_expr(element)); 677 + let arguments_docs = elements.iter().map(|element| self.const_expr(element)); 672 678 let tuple_doc = break_("#(", "#(") 673 - .append(join(args_docs, break_(",", ", ")).next_break_fits(NextBreakFitsMode::Disabled)) 679 + .append( 680 + join(arguments_docs, break_(",", ", ")) 681 + .next_break_fits(NextBreakFitsMode::Disabled), 682 + ) 674 683 .nest(INDENT); 675 684 676 685 let comments = self.pop_comments(location.end); ··· 710 719 &mut self, 711 720 module: &'a Option<(EcoString, SrcSpan)>, 712 721 name: &'a str, 713 - args: &'a [TypeAst], 722 + arguments: &'a [TypeAst], 714 723 location: &SrcSpan, 715 724 _name_location: &SrcSpan, 716 725 ) -> Document<'a> { ··· 719 728 .map(|(qualifier, _)| qualifier.to_doc().append(".").append(name)) 720 729 .unwrap_or_else(|| name.to_doc()); 721 730 722 - if args.is_empty() { 731 + if arguments.is_empty() { 723 732 head 724 733 } else { 725 - head.append(self.type_arguments(args, location)) 734 + head.append(self.type_arguments(arguments, location)) 726 735 } 727 736 } 728 737 ··· 732 741 733 742 TypeAst::Constructor(TypeAstConstructor { 734 743 name, 735 - arguments: args, 744 + arguments, 736 745 module, 737 746 location, 738 747 name_location, 739 - }) => self.type_ast_constructor(module, name, args, location, name_location), 748 + }) => self.type_ast_constructor(module, name, arguments, location, name_location), 740 749 741 750 TypeAst::Fn(TypeAstFn { 742 - arguments: args, 751 + arguments, 743 752 return_, 744 753 location, 745 754 }) => "fn" 746 755 .to_doc() 747 - .append(self.type_arguments(args, location)) 756 + .append(self.type_arguments(arguments, location)) 748 757 .group() 749 758 .append(" ->") 750 759 .append(break_("", " ").append(self.type_ast(return_)).nest(INDENT)), ··· 758 767 .group() 759 768 } 760 769 761 - fn type_arguments<'a>(&mut self, args: &'a [TypeAst], location: &SrcSpan) -> Document<'a> { 762 - let args = args.iter().map(|type_| self.type_ast(type_)).collect_vec(); 763 - self.wrap_args(args, location.end) 770 + fn type_arguments<'a>(&mut self, arguments: &'a [TypeAst], location: &SrcSpan) -> Document<'a> { 771 + let arguments = arguments 772 + .iter() 773 + .map(|type_| self.type_ast(type_)) 774 + .collect_vec(); 775 + self.wrap_arguments(arguments, location.end) 764 776 } 765 777 766 778 pub fn type_alias<'a>( 767 779 &mut self, 768 780 publicity: Publicity, 769 781 name: &'a str, 770 - args: &'a [SpannedString], 782 + arguments: &'a [SpannedString], 771 783 type_: &'a TypeAst, 772 784 deprecation: &'a Deprecation, 773 785 location: &SrcSpan, ··· 778 790 .to_doc(); 779 791 780 792 let head = docvec![attributes, pub_(publicity), "type ", name]; 781 - let head = if args.is_empty() { 793 + let head = if arguments.is_empty() { 782 794 head 783 795 } else { 784 - let args = args.iter().map(|(_, e)| e.to_doc()).collect_vec(); 785 - head.append(self.wrap_args(args, location.end).group()) 796 + let arguments = arguments.iter().map(|(_, e)| e.to_doc()).collect_vec(); 797 + head.append(self.wrap_arguments(arguments, location.end).group()) 786 798 }; 787 799 788 800 head.append(" =") ··· 808 820 .to_doc(); 809 821 810 822 // Fn name and args 811 - let args = function 823 + let arguments = function 812 824 .arguments 813 825 .iter() 814 826 .map(|argument| self.fn_arg(argument)) ··· 822 834 .expect("Function in a statement must be named") 823 835 .1, 824 836 ) 825 - .append(self.wrap_args(args, function.location.end)); 837 + .append(self.wrap_arguments(arguments, function.location.end)); 826 838 827 839 // Add return annotation 828 840 let signature = match &function.return_annotation { ··· 856 868 857 869 fn expr_fn<'a>( 858 870 &mut self, 859 - args: &'a [UntypedArg], 871 + arguments: &'a [UntypedArg], 860 872 return_annotation: Option<&'a TypeAst>, 861 873 body: &'a Vec1<UntypedStatement>, 862 874 location: &SrcSpan, 863 875 end_of_head_byte_index: &u32, 864 876 ) -> Document<'a> { 865 - let args_docs = args.iter().map(|arg| self.fn_arg(arg)).collect_vec(); 866 - let args = self 867 - .wrap_args(args_docs, *end_of_head_byte_index) 877 + let arguments_docs = arguments 878 + .iter() 879 + .map(|argument| self.fn_arg(argument)) 880 + .collect_vec(); 881 + let arguments = self 882 + .wrap_arguments(arguments_docs, *end_of_head_byte_index) 868 883 .group() 869 884 .next_break_fits(NextBreakFitsMode::Disabled); 870 885 // ^^^ We add this so that when an expression function is passed as ··· 883 898 // These are some of the ways we could tweak the look of expression 884 899 // functions in the future if people are not satisfied with it. 885 900 886 - let header = "fn".to_doc().append(args); 901 + let header = "fn".to_doc().append(arguments); 887 902 888 903 let header = match return_annotation { 889 904 None => header, ··· 1014 1029 1015 1030 UntypedExpr::Fn { 1016 1031 return_annotation, 1017 - arguments: args, 1032 + arguments, 1018 1033 body, 1019 1034 location, 1020 1035 end_of_head_byte_index, 1021 1036 .. 1022 1037 } => self.expr_fn( 1023 - args, 1038 + arguments, 1024 1039 return_annotation.as_ref(), 1025 1040 body, 1026 1041 location, ··· 1035 1050 1036 1051 UntypedExpr::Call { 1037 1052 fun, 1038 - arguments: args, 1053 + arguments, 1039 1054 location, 1040 1055 .. 1041 - } => self.call(fun, args, location), 1056 + } => self.call(fun, arguments, location), 1042 1057 1043 1058 UntypedExpr::BinOp { 1044 1059 name, left, right, .. ··· 1081 1096 UntypedExpr::RecordUpdate { 1082 1097 constructor, 1083 1098 record, 1084 - arguments: args, 1099 + arguments, 1085 1100 location, 1086 1101 .. 1087 - } => self.record_update(constructor, record, args, location), 1102 + } => self.record_update(constructor, record, arguments, location), 1088 1103 }; 1089 1104 commented(document, comments) 1090 1105 } ··· 1183 1198 fn pattern_constructor<'a>( 1184 1199 &mut self, 1185 1200 name: &'a str, 1186 - args: &'a [CallArg<UntypedPattern>], 1201 + arguments: &'a [CallArg<UntypedPattern>], 1187 1202 module: &'a Option<(EcoString, SrcSpan)>, 1188 1203 spread: Option<SrcSpan>, 1189 1204 location: &SrcSpan, ··· 1191 1206 fn is_breakable(expr: &UntypedPattern) -> bool { 1192 1207 match expr { 1193 1208 Pattern::Tuple { .. } | Pattern::List { .. } | Pattern::BitArray { .. } => true, 1194 - Pattern::Constructor { 1195 - arguments: args, .. 1196 - } => !args.is_empty(), 1209 + Pattern::Constructor { arguments, .. } => !arguments.is_empty(), 1197 1210 _ => false, 1198 1211 } 1199 1212 } ··· 1203 1216 None => name.to_doc(), 1204 1217 }; 1205 1218 1206 - if args.is_empty() && spread.is_some() { 1219 + if arguments.is_empty() && spread.is_some() { 1207 1220 name.append("(..)") 1208 - } else if args.is_empty() { 1221 + } else if arguments.is_empty() { 1209 1222 name 1210 1223 } else if spread.is_some() { 1211 - let args = args.iter().map(|a| self.pattern_call_arg(a)).collect_vec(); 1212 - name.append(self.wrap_args_with_spread(args, location.end)) 1224 + let arguments = arguments 1225 + .iter() 1226 + .map(|argument| self.pattern_call_arg(argument)) 1227 + .collect_vec(); 1228 + name.append(self.wrap_arguments_with_spread(arguments, location.end)) 1213 1229 } else { 1214 - match args { 1215 - [arg] if is_breakable(&arg.value) => name 1230 + match arguments { 1231 + [argument] if is_breakable(&argument.value) => name 1216 1232 .append("(") 1217 - .append(self.pattern_call_arg(arg)) 1233 + .append(self.pattern_call_arg(argument)) 1218 1234 .append(")") 1219 1235 .group(), 1220 1236 1221 1237 _ => { 1222 - let args = args.iter().map(|a| self.pattern_call_arg(a)).collect_vec(); 1223 - name.append(self.wrap_args(args, location.end)).group() 1238 + let arguments = arguments 1239 + .iter() 1240 + .map(|argument| self.pattern_call_arg(argument)) 1241 + .collect_vec(); 1242 + name.append(self.wrap_arguments(arguments, location.end)) 1243 + .group() 1224 1244 } 1225 1245 } 1226 1246 } ··· 1229 1249 fn call<'a>( 1230 1250 &mut self, 1231 1251 fun: &'a UntypedExpr, 1232 - args: &'a [CallArg<UntypedExpr>], 1252 + arguments: &'a [CallArg<UntypedExpr>], 1233 1253 location: &SrcSpan, 1234 1254 ) -> Document<'a> { 1235 1255 let expr = match fun { ··· 1259 1279 | UntypedExpr::NegateInt { .. } => self.expr(fun), 1260 1280 }; 1261 1281 1262 - let arity = args.len(); 1263 - self.append_inlinable_wrapped_args( 1282 + let arity = arguments.len(); 1283 + self.append_inlinable_wrapped_arguments( 1264 1284 expr, 1265 - args, 1285 + arguments, 1266 1286 location, 1267 - |arg| &arg.value, 1287 + |argument| &argument.value, 1268 1288 |self_, arg| self_.call_arg(arg, arity), 1269 1289 ) 1270 1290 } ··· 1289 1309 }; 1290 1310 } 1291 1311 1292 - self.append_inlinable_wrapped_args( 1312 + self.append_inlinable_wrapped_arguments( 1293 1313 "#".to_doc(), 1294 1314 elements, 1295 1315 location, ··· 1303 1323 // resulting document will try to first split that before splitting all the 1304 1324 // other arguments. 1305 1325 // This is used for function calls and tuples. 1306 - fn append_inlinable_wrapped_args<'a, 'b, T, ToExpr, ToDoc>( 1326 + fn append_inlinable_wrapped_arguments<'a, 'b, T, ToExpr, ToDoc>( 1307 1327 &mut self, 1308 1328 doc: Document<'a>, 1309 1329 values: &'b [T], ··· 1332 1352 1333 1353 docs.append(&mut vec![last_value_doc]); 1334 1354 1335 - doc.append(self.wrap_function_call_args(docs, location)) 1355 + doc.append(self.wrap_function_call_arguments(docs, location)) 1336 1356 .next_break_fits(NextBreakFitsMode::Disabled) 1337 1357 .group() 1338 1358 } 1339 1359 1340 1360 Some(_) | None => { 1341 1361 let docs = values.iter().map(|value| to_doc(self, value)).collect_vec(); 1342 - doc.append(self.wrap_function_call_args(docs, location)) 1362 + doc.append(self.wrap_function_call_arguments(docs, location)) 1343 1363 .group() 1344 1364 } 1345 1365 } ··· 1392 1412 &mut self, 1393 1413 constructor: &'a UntypedExpr, 1394 1414 record: &'a RecordBeingUpdated, 1395 - args: &'a [UntypedRecordUpdateArg], 1415 + arguments: &'a [UntypedRecordUpdateArg], 1396 1416 location: &SrcSpan, 1397 1417 ) -> Document<'a> { 1398 1418 let constructor_doc: Document<'a> = self.expr(constructor); 1399 1419 let pieces = std::iter::once(RecordUpdatePiece::Record(record)) 1400 - .chain(args.iter().map(RecordUpdatePiece::Argument)) 1420 + .chain(arguments.iter().map(RecordUpdatePiece::Argument)) 1401 1421 .collect_vec(); 1402 1422 1403 - self.append_inlinable_wrapped_args( 1423 + self.append_inlinable_wrapped_arguments( 1404 1424 constructor_doc, 1405 1425 &pieces, 1406 1426 location, ··· 1609 1629 { 1610 1630 let expr = self.expr(fun); 1611 1631 let arity = rest.len(); 1612 - self.append_inlinable_wrapped_args( 1632 + self.append_inlinable_wrapped_arguments( 1613 1633 expr, 1614 1634 rest, 1615 1635 location, ··· 1627 1647 ) => { 1628 1648 let expr = self.expr(fun); 1629 1649 let arity = arguments.len(); 1630 - self.append_inlinable_wrapped_args( 1650 + self.append_inlinable_wrapped_arguments( 1631 1651 expr, 1632 1652 arguments, 1633 1653 location, ··· 1652 1672 if self.any_comments(constructor.location.end) { 1653 1673 attributes 1654 1674 .append(constructor.name.as_str().to_doc()) 1655 - .append(self.wrap_args(vec![], constructor.location.end)) 1675 + .append(self.wrap_arguments(vec![], constructor.location.end)) 1656 1676 .group() 1657 1677 } else { 1658 1678 attributes.append(constructor.name.as_str().to_doc()) 1659 1679 } 1660 1680 } else { 1661 - let args = constructor 1681 + let arguments = constructor 1662 1682 .arguments 1663 1683 .iter() 1664 1684 .map( ··· 1684 1704 1685 1705 attributes 1686 1706 .append(constructor.name.as_str().to_doc()) 1687 - .append(self.wrap_args(args, constructor.location.end).group()) 1707 + .append( 1708 + self.wrap_arguments(arguments, constructor.location.end) 1709 + .group(), 1710 + ) 1688 1711 }; 1689 1712 1690 1713 commented(doc_comments.append(doc).group(), comments) ··· 1704 1727 .append(if ct.parameters.is_empty() { 1705 1728 ct.name.clone().to_doc() 1706 1729 } else { 1707 - let args = ct.parameters.iter().map(|(_, e)| e.to_doc()).collect_vec(); 1730 + let arguments = ct.parameters.iter().map(|(_, e)| e.to_doc()).collect_vec(); 1708 1731 ct.name 1709 1732 .clone() 1710 1733 .to_doc() 1711 - .append(self.wrap_args(args, ct.location.end)) 1734 + .append(self.wrap_arguments(arguments, ct.location.end)) 1712 1735 .group() 1713 1736 }); 1714 1737 ··· 2238 2261 2239 2262 Pattern::Constructor { 2240 2263 name, 2241 - arguments: args, 2264 + arguments, 2242 2265 module, 2243 2266 spread, 2244 2267 location, 2245 2268 .. 2246 - } => self.pattern_constructor(name, args, module, *spread, location), 2269 + } => self.pattern_constructor(name, arguments, module, *spread, location), 2247 2270 2248 2271 Pattern::Tuple { 2249 2272 elements, location, .. 2250 2273 } => { 2251 - let args = elements 2274 + let arguments = elements 2252 2275 .iter() 2253 2276 .map(|element| self.pattern(element)) 2254 2277 .collect_vec(); 2255 2278 "#".to_doc() 2256 - .append(self.wrap_args(args, location.end)) 2279 + .append(self.wrap_arguments(arguments, location.end)) 2257 2280 .group() 2258 2281 } 2259 2282 ··· 2681 2704 } 2682 2705 } 2683 2706 2684 - pub fn wrap_function_call_args<'a, I>(&mut self, args: I, location: &SrcSpan) -> Document<'a> 2707 + pub fn wrap_function_call_arguments<'a, I>( 2708 + &mut self, 2709 + arguments: I, 2710 + location: &SrcSpan, 2711 + ) -> Document<'a> 2685 2712 where 2686 2713 I: IntoIterator<Item = Document<'a>>, 2687 2714 { 2688 - let mut args = args.into_iter().peekable(); 2689 - if args.peek().is_none() { 2715 + let mut arguments = arguments.into_iter().peekable(); 2716 + if arguments.peek().is_none() { 2690 2717 return "()".to_doc(); 2691 2718 } 2692 2719 2693 - let args_doc = break_("", "") 2694 - .append(join(args, break_(",", ", "))) 2720 + let arguments_doc = break_("", "") 2721 + .append(join(arguments, break_(",", ", "))) 2695 2722 .nest_if_broken(INDENT); 2696 2723 2697 2724 // We get all remaining comments that come before the call's closing ··· 2707 2734 } 2708 2735 }; 2709 2736 2710 - "(".to_doc().append(args_doc).append(closing_parens).group() 2737 + "(".to_doc() 2738 + .append(arguments_doc) 2739 + .append(closing_parens) 2740 + .group() 2711 2741 } 2712 2742 2713 - pub fn wrap_args<'a, I>(&mut self, args: I, comments_limit: u32) -> Document<'a> 2743 + pub fn wrap_arguments<'a, I>(&mut self, arguments: I, comments_limit: u32) -> Document<'a> 2714 2744 where 2715 2745 I: IntoIterator<Item = Document<'a>>, 2716 2746 { 2717 - let mut args = args.into_iter().peekable(); 2718 - if args.peek().is_none() { 2747 + let mut arguments = arguments.into_iter().peekable(); 2748 + if arguments.peek().is_none() { 2719 2749 let comments = self.pop_comments(comments_limit); 2720 2750 return match printed_comments(comments, false) { 2721 2751 Some(comments) => "(" ··· 2729 2759 None => "()".to_doc(), 2730 2760 }; 2731 2761 } 2732 - let doc = break_("(", "(").append(join(args, break_(",", ", "))); 2762 + let doc = break_("(", "(").append(join(arguments, break_(",", ", "))); 2733 2763 2734 2764 // Include trailing comments if there are any 2735 2765 let comments = self.pop_comments(comments_limit); ··· 2748 2778 } 2749 2779 } 2750 2780 2751 - pub fn wrap_args_with_spread<'a, I>(&mut self, args: I, comments_limit: u32) -> Document<'a> 2781 + pub fn wrap_arguments_with_spread<'a, I>( 2782 + &mut self, 2783 + arguments: I, 2784 + comments_limit: u32, 2785 + ) -> Document<'a> 2752 2786 where 2753 2787 I: IntoIterator<Item = Document<'a>>, 2754 2788 { 2755 - let mut args = args.into_iter().peekable(); 2756 - if args.peek().is_none() { 2757 - return self.wrap_args(args, comments_limit); 2789 + let mut arguments = arguments.into_iter().peekable(); 2790 + if arguments.peek().is_none() { 2791 + return self.wrap_arguments(arguments, comments_limit); 2758 2792 } 2759 2793 let doc = break_("(", "(") 2760 - .append(join(args, break_(",", ", "))) 2794 + .append(join(arguments, break_(",", ", "))) 2761 2795 .append(break_(",", ", ")) 2762 2796 .append(".."); 2763 2797
+21 -17
compiler-core/src/javascript.rs
··· 653 653 function_doc, 654 654 head, 655 655 maybe_escape_identifier(name.as_str()), 656 - fun_args(function.arguments.as_slice(), generator.tail_recursion_used), 656 + fun_arguments(function.arguments.as_slice(), generator.tail_recursion_used), 657 657 " {", 658 658 docvec![line(), body].nest(INDENT).group(), 659 659 line(), ··· 736 736 document.to_pretty_string(80) 737 737 } 738 738 739 - fn fun_args(args: &'_ [TypedArg], tail_recursion_used: bool) -> Document<'_> { 739 + fn fun_arguments(arguments: &'_ [TypedArg], tail_recursion_used: bool) -> Document<'_> { 740 740 let mut discards = 0; 741 - wrap_args(args.iter().map(|a| match a.get_variable_name() { 742 - None => { 743 - let doc = if discards == 0 { 744 - "_".to_doc() 745 - } else { 746 - eco_format!("_{discards}").to_doc() 747 - }; 748 - discards += 1; 749 - doc 750 - } 751 - Some(name) if tail_recursion_used => eco_format!("loop${name}").to_doc(), 752 - Some(name) => maybe_escape_identifier(name).to_doc(), 753 - })) 741 + wrap_arguments( 742 + arguments 743 + .iter() 744 + .map(|argument| match argument.get_variable_name() { 745 + None => { 746 + let doc = if discards == 0 { 747 + "_".to_doc() 748 + } else { 749 + eco_format!("_{discards}").to_doc() 750 + }; 751 + discards += 1; 752 + doc 753 + } 754 + Some(name) if tail_recursion_used => eco_format!("loop${name}").to_doc(), 755 + Some(name) => maybe_escape_identifier(name).to_doc(), 756 + }), 757 + ) 754 758 } 755 759 756 - fn wrap_args<'a, I>(args: I) -> Document<'a> 760 + fn wrap_arguments<'a, I>(arguments: I) -> Document<'a> 757 761 where 758 762 I: IntoIterator<Item = Document<'a>>, 759 763 { 760 764 break_("", "") 761 - .append(join(args, break_(",", ", "))) 765 + .append(join(arguments, break_(",", ", "))) 762 766 .nest(INDENT) 763 767 .append(break_("", "")) 764 768 .surround("(", ")")
+4 -4
compiler-core/src/javascript/decision.rs
··· 1300 1300 Endianness::Little => "false", 1301 1301 }; 1302 1302 let signed = if signed { "true" } else { "false" }; 1303 - let args = join( 1303 + let arguments = join( 1304 1304 [ 1305 1305 bit_array.to_doc(), 1306 1306 start.to_doc(), ··· 1310 1310 ], 1311 1311 ", ".to_doc(), 1312 1312 ); 1313 - docvec!["bitArraySliceToInt(", args, ")"] 1313 + docvec!["bitArraySliceToInt(", arguments, ")"] 1314 1314 } 1315 1315 1316 1316 /// Generates the document that calls the `bitArraySliceToFloat` function, ··· 1331 1331 Endianness::Big => "true", 1332 1332 Endianness::Little => "false", 1333 1333 }; 1334 - let args = join( 1334 + let arguments = join( 1335 1335 [ 1336 1336 bit_array.to_doc(), 1337 1337 start.to_doc(), ··· 1340 1340 ], 1341 1341 ", ".to_doc(), 1342 1342 ); 1343 - docvec!["bitArraySliceToFloat(", args, ")"] 1343 + docvec!["bitArraySliceToFloat(", arguments, ")"] 1344 1344 } 1345 1345 1346 1346 /// Generates the document that calls the `bitArraySlice` function, with
+56 -47
compiler-core/src/javascript/expression.rs
··· 231 231 pub fn function_body( 232 232 &mut self, 233 233 body: &'a [TypedStatement], 234 - args: &'a [TypedArg], 234 + arguments: &'a [TypedArg], 235 235 ) -> Document<'a> { 236 236 let body = self.statements(body); 237 237 if self.tail_recursion_used { 238 - self.tail_call_loop(body, args) 238 + self.tail_call_loop(body, arguments) 239 239 } else { 240 240 body 241 241 } 242 242 } 243 243 244 - fn tail_call_loop(&mut self, body: Document<'a>, args: &'a [TypedArg]) -> Document<'a> { 245 - let loop_assignments = concat(args.iter().flat_map(Arg::get_variable_name).map(|name| { 246 - let var = maybe_escape_identifier(name); 247 - docvec!["let ", var, " = loop$", name, ";", line()] 248 - })); 244 + fn tail_call_loop(&mut self, body: Document<'a>, arguments: &'a [TypedArg]) -> Document<'a> { 245 + let loop_assignments = concat(arguments.iter().flat_map(Arg::get_variable_name).map( 246 + |name| { 247 + let var = maybe_escape_identifier(name); 248 + docvec!["let ", var, " = loop$", name, ";", line()] 249 + }, 250 + )); 249 251 docvec![ 250 252 "while (true) {", 251 253 docvec![line(), loop_assignments, body].nest(INDENT), ··· 308 310 .. 309 311 } => decision::case(compiled_case, clauses, subjects, self), 310 312 311 - TypedExpr::Call { fun, args, .. } => self.call(fun, args), 312 - TypedExpr::Fn { args, body, .. } => self.fn_(args, body), 313 + TypedExpr::Call { fun, arguments, .. } => self.call(fun, arguments), 314 + TypedExpr::Fn { 315 + arguments, body, .. 316 + } => self.fn_(arguments, body), 313 317 314 318 TypedExpr::RecordAccess { record, label, .. } => self.record_access(record, label), 315 319 TypedExpr::RecordUpdate { 316 320 record_assignment, 317 321 constructor, 318 - args, 322 + arguments, 319 323 .. 320 - } => self.record_update(record_assignment, constructor, args), 324 + } => self.record_update(record_assignment, constructor, arguments), 321 325 322 326 TypedExpr::Var { 323 327 name, constructor, .. ··· 909 913 location: SrcSpan, 910 914 ) -> Document<'a> { 911 915 let (subject_document, mut fields) = match subject { 912 - TypedExpr::Call { fun, args, .. } => { 913 - let argument_variables = args 916 + TypedExpr::Call { fun, arguments, .. } => { 917 + let argument_variables = arguments 914 918 .iter() 915 919 .map(|element| { 916 920 self.not_in_tail_position(Some(Ordering::Strict), |this| { ··· 919 923 }) 920 924 .collect_vec(); 921 925 ( 922 - self.call_with_doc_args(fun, argument_variables.clone()), 926 + self.call_with_doc_arguments(fun, argument_variables.clone()), 923 927 vec![ 924 928 ("kind", string("function_call")), 925 929 ( 926 930 "arguments", 927 - array(argument_variables.into_iter().zip(args).map( 931 + array(argument_variables.into_iter().zip(arguments).map( 928 932 |(variable, argument)| { 929 933 self.asserted_expression( 930 934 AssertExpression::from_expression(&argument.value), ··· 1247 1251 }) 1248 1252 .collect_vec(); 1249 1253 1250 - self.call_with_doc_args(fun, arguments) 1254 + self.call_with_doc_arguments(fun, arguments) 1251 1255 } 1252 1256 1253 - fn call_with_doc_args( 1257 + fn call_with_doc_arguments( 1254 1258 &mut self, 1255 1259 fun: &'a TypedExpr, 1256 1260 arguments: Vec<Document<'a>>, ··· 1363 1367 std::mem::swap(&mut self.current_function, &mut current_function); 1364 1368 1365 1369 docvec![ 1366 - docvec![fun_args(arguments, false), " => {", break_("", " "), result] 1367 - .nest(INDENT) 1368 - .append(break_("", " ")) 1369 - .group(), 1370 + docvec![ 1371 + fun_arguments(arguments, false), 1372 + " => {", 1373 + break_("", " "), 1374 + result 1375 + ] 1376 + .nest(INDENT) 1377 + .append(break_("", " ")) 1378 + .group(), 1370 1379 "}", 1371 1380 ] 1372 1381 } ··· 1382 1391 &mut self, 1383 1392 record: &'a Option<Box<TypedAssignment>>, 1384 1393 constructor: &'a TypedExpr, 1385 - args: &'a [TypedCallArg], 1394 + arguments: &'a [TypedCallArg], 1386 1395 ) -> Document<'a> { 1387 1396 match record.as_ref() { 1388 1397 Some(record) => docvec![ 1389 1398 self.not_in_tail_position(None, |this| this.assignment(record)), 1390 1399 line(), 1391 - self.call(constructor, args), 1400 + self.call(constructor, arguments), 1392 1401 ], 1393 - None => self.call(constructor, args), 1402 + None => self.call(constructor, arguments), 1394 1403 } 1395 1404 } 1396 1405 ··· 1433 1442 let right = 1434 1443 self.not_in_tail_position(Some(Ordering::Strict), |this| this.child_expression(right)); 1435 1444 self.tracker.int_division_used = true; 1436 - docvec!["divideInt", wrap_args([left, right])] 1445 + docvec!["divideInt", wrap_arguments([left, right])] 1437 1446 } 1438 1447 1439 1448 fn remainder_int(&mut self, left: &'a TypedExpr, right: &'a TypedExpr) -> Document<'a> { ··· 1442 1451 let right = 1443 1452 self.not_in_tail_position(Some(Ordering::Strict), |this| this.child_expression(right)); 1444 1453 self.tracker.int_remainder_used = true; 1445 - docvec!["remainderInt", wrap_args([left, right])] 1454 + docvec!["remainderInt", wrap_arguments([left, right])] 1446 1455 } 1447 1456 1448 1457 fn div_float(&mut self, left: &'a TypedExpr, right: &'a TypedExpr) -> Document<'a> { ··· 1451 1460 let right = 1452 1461 self.not_in_tail_position(Some(Ordering::Strict), |this| this.child_expression(right)); 1453 1462 self.tracker.float_division_used = true; 1454 - docvec!["divideFloat", wrap_args([left, right])] 1463 + docvec!["divideFloat", wrap_arguments([left, right])] 1455 1464 } 1456 1465 1457 1466 fn equal( ··· 1504 1513 // Record that we need to import the prelude's isEqual function into the module 1505 1514 self.tracker.object_equality_used = true; 1506 1515 // Construct the call 1507 - let args = wrap_args([left, right]); 1516 + let arguments = wrap_arguments([left, right]); 1508 1517 let operator = if should_be_equal { 1509 1518 "isEqual" 1510 1519 } else { 1511 1520 "!isEqual" 1512 1521 }; 1513 - docvec![operator, args] 1522 + docvec![operator, arguments] 1514 1523 } 1515 1524 1516 1525 fn print_bin_op( ··· 1549 1558 BinOp::MultInt | BinOp::MultFloat => docvec![left, " * ", right], 1550 1559 BinOp::RemainderInt => { 1551 1560 self.tracker.int_remainder_used = true; 1552 - docvec!["remainderInt", wrap_args([left, right])] 1561 + docvec!["remainderInt", wrap_arguments([left, right])] 1553 1562 } 1554 1563 BinOp::DivInt => { 1555 1564 self.tracker.int_division_used = true; 1556 - docvec!["divideInt", wrap_args([left, right])] 1565 + docvec!["divideInt", wrap_arguments([left, right])] 1557 1566 } 1558 1567 BinOp::DivFloat => { 1559 1568 self.tracker.float_division_used = true; 1560 - docvec!["divideFloat", wrap_args([left, right])] 1569 + docvec!["divideFloat", wrap_arguments([left, right])] 1561 1570 } 1562 1571 } 1563 1572 } ··· 1596 1605 1597 1606 docvec![ 1598 1607 "throw makeError", 1599 - wrap_args([ 1608 + wrap_arguments([ 1600 1609 string(error_name), 1601 1610 "FILEPATH".to_doc(), 1602 1611 module, ··· 1686 1695 Constant::Record { type_, .. } if type_.is_nil() => "undefined".to_doc(), 1687 1696 1688 1697 Constant::Record { 1689 - args, 1698 + arguments, 1690 1699 module, 1691 1700 name, 1692 1701 tag, ··· 1705 1714 // arguments then this is the constructor being referenced, not the 1706 1715 // function being called. 1707 1716 if let Some(arity) = type_.fn_arity() { 1708 - if args.is_empty() && arity != 0 { 1717 + if arguments.is_empty() && arity != 0 { 1709 1718 let arity = arity as u16; 1710 1719 return record_constructor(type_.clone(), None, name, arity, self.tracker); 1711 1720 } 1712 1721 } 1713 1722 1714 - let field_values = args 1723 + let field_values = arguments 1715 1724 .iter() 1716 - .map(|arg| self.constant_expression(context, &arg.value)) 1725 + .map(|argument| self.constant_expression(context, &argument.value)) 1717 1726 .collect_vec(); 1718 1727 1719 1728 let constructor = construct_record( ··· 1958 1967 let left = self.wrapped_guard(left); 1959 1968 let right = self.wrapped_guard(right); 1960 1969 self.tracker.float_division_used = true; 1961 - docvec!["divideFloat", wrap_args([left, right])] 1970 + docvec!["divideFloat", wrap_arguments([left, right])] 1962 1971 } 1963 1972 1964 1973 ClauseGuard::DivInt { left, right, .. } => { 1965 1974 let left = self.wrapped_guard(left); 1966 1975 let right = self.wrapped_guard(right); 1967 1976 self.tracker.int_division_used = true; 1968 - docvec!["divideInt", wrap_args([left, right])] 1977 + docvec!["divideInt", wrap_arguments([left, right])] 1969 1978 } 1970 1979 1971 1980 ClauseGuard::RemainderInt { left, right, .. } => { 1972 1981 let left = self.wrapped_guard(left); 1973 1982 let right = self.wrapped_guard(right); 1974 1983 self.tracker.int_remainder_used = true; 1975 - docvec!["remainderInt", wrap_args([left, right])] 1984 + docvec!["remainderInt", wrap_arguments([left, right])] 1976 1985 } 1977 1986 1978 1987 ClauseGuard::Or { left, right, .. } => { ··· 2067 2076 Constant::Record { type_, .. } if type_.is_nil() => "undefined".to_doc(), 2068 2077 2069 2078 Constant::Record { 2070 - args, 2079 + arguments, 2071 2080 module, 2072 2081 name, 2073 2082 tag, ··· 2086 2095 // arguments then this is the constructor being referenced, not the 2087 2096 // function being called. 2088 2097 if let Some(arity) = type_.fn_arity() { 2089 - if args.is_empty() && arity != 0 { 2098 + if arguments.is_empty() && arity != 0 { 2090 2099 let arity = arity as u16; 2091 2100 return record_constructor(type_.clone(), None, name, arity, self.tracker); 2092 2101 } 2093 2102 } 2094 2103 2095 - let field_values = args 2104 + let field_values = arguments 2096 2105 .iter() 2097 - .map(|arg| self.guard_constant_expression(&arg.value)) 2106 + .map(|argument| self.guard_constant_expression(&argument.value)) 2098 2107 .collect_vec(); 2099 2108 construct_record( 2100 2109 module.as_ref().map(|(module, _)| module.as_str()), ··· 2302 2311 I::IntoIter: DoubleEndedIterator + ExactSizeIterator, 2303 2312 { 2304 2313 elements.into_iter().rev().fold(tail, |tail, element| { 2305 - let args = call_arguments([element, tail]); 2306 - docvec!["listPrepend", args] 2314 + let arguments = call_arguments([element, tail]); 2315 + docvec!["listPrepend", arguments] 2307 2316 }) 2308 2317 } 2309 2318 ··· 2494 2503 ";" 2495 2504 ]; 2496 2505 docvec![ 2497 - docvec![wrap_args(vars), " => {", break_("", " "), body] 2506 + docvec![wrap_arguments(vars), " => {", break_("", " "), body] 2498 2507 .nest(INDENT) 2499 2508 .append(break_("", " ")) 2500 2509 .group(),
+97 -65
compiler-core/src/javascript/typescript.rs
··· 27 27 use itertools::Itertools; 28 28 use std::{collections::HashMap, ops::Deref, sync::Arc}; 29 29 30 - use super::{INDENT, import::Imports, join, line, lines, wrap_args}; 30 + use super::{INDENT, import::Imports, join, line, lines, wrap_arguments}; 31 31 32 32 /// When rendering a type variable to an TypeScript type spec we need all type 33 33 /// variables with the same id to end up with the same name in the generated ··· 66 66 if generic_names.is_empty() { 67 67 super::nil() 68 68 } else { 69 - wrap_generic_args(generic_names) 69 + wrap_generic_arguments(generic_names) 70 70 }, 71 71 ] 72 72 } ··· 99 99 } 100 100 TypeVar::Link { type_ } => generic_ids(type_, ids), 101 101 }, 102 - Type::Named { args, .. } => { 103 - for arg in args { 104 - generic_ids(arg, ids) 102 + Type::Named { arguments, .. } => { 103 + for argument in arguments { 104 + generic_ids(argument, ids) 105 105 } 106 106 } 107 - Type::Fn { args, return_ } => { 108 - for arg in args { 109 - generic_ids(arg, ids) 107 + Type::Fn { arguments, return_ } => { 108 + for argument in arguments { 109 + generic_ids(argument, ids) 110 110 } 111 111 generic_ids(return_, ids); 112 112 } ··· 129 129 .group() 130 130 } 131 131 132 - fn wrap_generic_args<'a, I>(args: I) -> Document<'a> 132 + fn wrap_generic_arguments<'a, I>(arguments: I) -> Document<'a> 133 133 where 134 134 I: IntoIterator<Item = Document<'a>>, 135 135 { 136 136 break_("", "") 137 - .append(join(args, break_(",", ", "))) 137 + .append(join(arguments, break_(",", ", "))) 138 138 .nest(INDENT) 139 139 .append(break_("", "")) 140 140 .surround("<", ">") ··· 288 288 Type::Named { 289 289 package, 290 290 module, 291 - args, 291 + arguments, 292 292 .. 293 293 } => { 294 294 let is_prelude = module == "gleam" && package.is_empty(); ··· 298 298 self.register_import(imports, package, module); 299 299 } 300 300 301 - for arg in args { 302 - self.collect_imports_for_type(arg, imports); 301 + for argument in arguments { 302 + self.collect_imports_for_type(argument, imports); 303 303 } 304 304 } 305 - Type::Fn { args, return_ } => { 306 - for arg in args { 307 - self.collect_imports_for_type(arg, imports); 305 + Type::Fn { arguments, return_ } => { 306 + for argument in arguments { 307 + self.collect_imports_for_type(argument, imports); 308 308 } 309 309 self.collect_imports_for_type(return_, imports); 310 310 } ··· 501 501 line(), 502 502 // First add the constructor 503 503 "constructor", 504 - wrap_args(constructor.arguments.iter().enumerate().map(|(i, arg)| { 505 - let name = arg 506 - .label 507 - .as_ref() 508 - .map(|(_, s)| super::maybe_escape_identifier(s)) 509 - .unwrap_or_else(|| eco_format!("argument${i}")) 510 - .to_doc(); 511 - docvec![name, ": ", self.do_print_force_generic_param(&arg.type_)] 512 - })), 504 + wrap_arguments( 505 + constructor 506 + .arguments 507 + .iter() 508 + .enumerate() 509 + .map(|(i, argument)| { 510 + let name = argument 511 + .label 512 + .as_ref() 513 + .map(|(_, s)| super::maybe_escape_identifier(s)) 514 + .unwrap_or_else(|| eco_format!("argument${i}")) 515 + .to_doc(); 516 + docvec![ 517 + name, 518 + ": ", 519 + self.do_print_force_generic_param(&argument.type_) 520 + ] 521 + }) 522 + ), 513 523 ";", 514 524 line(), 515 525 line(), ··· 550 560 fn module_function( 551 561 &mut self, 552 562 name: &'a EcoString, 553 - args: &'a [TypedArg], 563 + arguments: &'a [TypedArg], 554 564 return_type: &'a Arc<Type>, 555 565 ) -> Document<'a> { 556 566 let generic_usages = collect_generic_usages( 557 567 HashMap::new(), 558 - std::iter::once(return_type).chain(args.iter().map(|a| &a.type_)), 568 + std::iter::once(return_type).chain(arguments.iter().map(|a| &a.type_)), 559 569 ); 560 570 let generic_names: Vec<Document<'_>> = generic_usages 561 571 .iter() ··· 570 580 if generic_names.is_empty() { 571 581 super::nil() 572 582 } else { 573 - wrap_generic_args(generic_names) 583 + wrap_generic_arguments(generic_names) 574 584 }, 575 - wrap_args( 576 - args.iter() 577 - .enumerate() 578 - .map(|(i, a)| match a.get_variable_name() { 579 - None => { 580 - docvec![ 581 - "x", 582 - i, 583 - ": ", 584 - self.print_type_with_generic_usages(&a.type_, &generic_usages) 585 - ] 586 - } 587 - Some(name) => docvec![ 588 - super::maybe_escape_identifier(name), 585 + wrap_arguments(arguments.iter().enumerate().map(|(i, argument)| { 586 + match argument.get_variable_name() { 587 + None => { 588 + docvec![ 589 + "x", 590 + i, 589 591 ": ", 590 - self.print_type_with_generic_usages(&a.type_, &generic_usages) 591 - ], 592 - }), 593 - ), 592 + self.print_type_with_generic_usages(&argument.type_, &generic_usages) 593 + ] 594 + } 595 + Some(name) => docvec![ 596 + super::maybe_escape_identifier(name), 597 + ": ", 598 + self.print_type_with_generic_usages(&argument.type_, &generic_usages) 599 + ], 600 + } 601 + }),), 594 602 ": ", 595 603 self.print_type_with_generic_usages(return_type, &generic_usages), 596 604 ";", ··· 640 648 Type::Var { type_ } => self.print_var(&type_.borrow(), generic_usages, false), 641 649 642 650 Type::Named { 643 - name, module, args, .. 644 - } if is_prelude_module(module) => self.print_prelude_type(name, args, generic_usages), 651 + name, 652 + module, 653 + arguments, 654 + .. 655 + } if is_prelude_module(module) => { 656 + self.print_prelude_type(name, arguments, generic_usages) 657 + } 645 658 646 659 Type::Named { 647 - name, args, module, .. 648 - } => self.print_type_app(name, args, module, generic_usages), 660 + name, 661 + arguments, 662 + module, 663 + .. 664 + } => self.print_type_app(name, arguments, module, generic_usages), 649 665 650 - Type::Fn { args, return_ } => self.print_fn(args, return_, generic_usages), 666 + Type::Fn { arguments, return_ } => self.print_fn(arguments, return_, generic_usages), 651 667 652 668 Type::Tuple { elements } => tuple( 653 669 elements ··· 662 678 Type::Var { type_ } => self.print_var(&type_.borrow(), None, true), 663 679 664 680 Type::Named { 665 - name, module, args, .. 666 - } if is_prelude_module(module) => self.print_prelude_type(name, args, None), 681 + name, 682 + module, 683 + arguments, 684 + .. 685 + } if is_prelude_module(module) => self.print_prelude_type(name, arguments, None), 667 686 668 687 Type::Named { 669 - name, args, module, .. 670 - } => self.print_type_app(name, args, module, None), 688 + name, 689 + arguments, 690 + module, 691 + .. 692 + } => self.print_type_app(name, arguments, module, None), 671 693 672 - Type::Fn { args, return_ } => self.print_fn(args, return_, None), 694 + Type::Fn { arguments, return_ } => self.print_fn(arguments, return_, None), 673 695 674 696 Type::Tuple { elements } => { 675 697 tuple(elements.iter().map(|element| self.do_print(element, None))) ··· 710 732 fn print_prelude_type( 711 733 &mut self, 712 734 name: &str, 713 - args: &[Arc<Type>], 735 + arguments: &[Arc<Type>], 714 736 generic_usages: Option<&HashMap<u64, u64>>, 715 737 ) -> Document<'static> { 716 738 match name { ··· 730 752 self.tracker.prelude_used = true; 731 753 docvec![ 732 754 "_.List", 733 - wrap_generic_args(args.iter().map(|x| self.do_print(x, generic_usages))) 755 + wrap_generic_arguments( 756 + arguments 757 + .iter() 758 + .map(|argument| self.do_print(argument, generic_usages)) 759 + ) 734 760 ] 735 761 } 736 762 "Result" => { 737 763 self.tracker.prelude_used = true; 738 764 docvec![ 739 765 "_.Result", 740 - wrap_generic_args(args.iter().map(|x| self.do_print(x, generic_usages))) 766 + wrap_generic_arguments( 767 + arguments.iter().map(|x| self.do_print(x, generic_usages)) 768 + ) 741 769 ] 742 770 } 743 771 // Getting here should mean we either forgot a built-in type or there is a ··· 752 780 fn print_type_app( 753 781 &mut self, 754 782 name: &str, 755 - args: &[Arc<Type>], 783 + arguments: &[Arc<Type>], 756 784 module: &str, 757 785 generic_usages: Option<&HashMap<u64, u64>>, 758 786 ) -> Document<'static> { ··· 765 793 docvec![self.module_name(module), ".", name] 766 794 } 767 795 }; 768 - if args.is_empty() { 796 + if arguments.is_empty() { 769 797 return name; 770 798 } 771 799 772 800 // If the App type takes arguments, pass them in as TypeScript generics 773 801 docvec![ 774 802 name, 775 - wrap_generic_args(args.iter().map(|a| self.do_print(a, generic_usages))) 803 + wrap_generic_arguments( 804 + arguments 805 + .iter() 806 + .map(|argument| self.do_print(argument, generic_usages)) 807 + ) 776 808 ] 777 809 } 778 810 ··· 780 812 /// 781 813 fn print_fn( 782 814 &mut self, 783 - args: &[Arc<Type>], 815 + arguments: &[Arc<Type>], 784 816 return_: &Type, 785 817 generic_usages: Option<&HashMap<u64, u64>>, 786 818 ) -> Document<'static> { 787 819 docvec![ 788 - wrap_args(args.iter().enumerate().map(|(idx, a)| docvec![ 820 + wrap_arguments(arguments.iter().enumerate().map(|(idx, argument)| docvec![ 789 821 "x", 790 822 idx, 791 823 ": ", 792 - self.do_print(a, generic_usages) 824 + self.do_print(argument, generic_usages) 793 825 ])), 794 826 " => ", 795 827 self.do_print(return_, generic_usages)
+175 -96
compiler-core/src/language_server/code_action.rs
··· 841 841 location: &'ast SrcSpan, 842 842 type_: &'ast Arc<Type>, 843 843 fun: &'ast TypedExpr, 844 - args: &'ast [TypedCallArg], 844 + arguments: &'ast [TypedCallArg], 845 845 ) { 846 846 let call_range = self.edits.src_span_to_lsp_range(*location); 847 847 if !within(self.params.range, call_range) { ··· 853 853 self.selected_call = Some(SelectedCall { 854 854 location, 855 855 field_map, 856 - arguments: args.iter().map(Self::empty_argument).collect(), 856 + arguments: arguments.iter().map(Self::empty_argument).collect(), 857 857 kind: SelectedCallKind::Value, 858 858 }) 859 859 } ··· 864 864 // we're inside a nested call. 865 865 let previous = self.use_right_hand_side_location; 866 866 self.use_right_hand_side_location = None; 867 - ast::visit::visit_typed_expr_call(self, location, type_, fun, args); 867 + ast::visit::visit_typed_expr_call(self, location, type_, fun, arguments); 868 868 self.use_right_hand_side_location = previous; 869 869 } 870 870 ··· 1225 1225 location: &'ast SrcSpan, 1226 1226 type_: &'ast Arc<Type>, 1227 1227 kind: &'ast FunctionLiteralKind, 1228 - args: &'ast [TypedArg], 1228 + arguments: &'ast [TypedArg], 1229 1229 body: &'ast Vec1<TypedStatement>, 1230 1230 return_annotation: &'ast Option<ast::TypeAst>, 1231 1231 ) { 1232 - ast::visit::visit_typed_expr_fn(self, location, type_, kind, args, body, return_annotation); 1232 + ast::visit::visit_typed_expr_fn( 1233 + self, 1234 + location, 1235 + type_, 1236 + kind, 1237 + arguments, 1238 + body, 1239 + return_annotation, 1240 + ); 1233 1241 1234 1242 // If the function doesn't have a head, we can't annotate it 1235 1243 let location = match kind { ··· 1247 1255 } 1248 1256 1249 1257 // Annotate each argument separately 1250 - for argument in args.iter() { 1258 + for argument in arguments.iter() { 1251 1259 // Don't annotate the argument if it's already annotated 1252 1260 if argument.annotation.is_some() { 1253 1261 continue; ··· 1382 1390 location: &'ast SrcSpan, 1383 1391 type_: &'ast Arc<Type>, 1384 1392 kind: &'ast FunctionLiteralKind, 1385 - args: &'ast [TypedArg], 1393 + arguments: &'ast [TypedArg], 1386 1394 body: &'ast Vec1<TypedStatement>, 1387 1395 return_annotation: &'ast Option<ast::TypeAst>, 1388 1396 ) { 1389 - for arg in args { 1390 - if let Some(annotation) = &arg.annotation { 1397 + for argument in arguments { 1398 + if let Some(annotation) = &argument.annotation { 1391 1399 self.visit_type_ast(annotation); 1392 1400 } 1393 1401 } 1394 1402 if let Some(return_) = return_annotation { 1395 1403 self.visit_type_ast(return_); 1396 1404 } 1397 - ast::visit::visit_typed_expr_fn(self, location, type_, kind, args, body, return_annotation); 1405 + ast::visit::visit_typed_expr_fn( 1406 + self, 1407 + location, 1408 + type_, 1409 + kind, 1410 + arguments, 1411 + body, 1412 + return_annotation, 1413 + ); 1398 1414 } 1399 1415 1400 1416 fn visit_typed_function(&mut self, fun: &'ast ast::TypedFunction) { ··· 1620 1636 location: &'ast SrcSpan, 1621 1637 type_: &'ast Arc<Type>, 1622 1638 kind: &'ast FunctionLiteralKind, 1623 - args: &'ast [TypedArg], 1639 + arguments: &'ast [TypedArg], 1624 1640 body: &'ast Vec1<TypedStatement>, 1625 1641 return_annotation: &'ast Option<ast::TypeAst>, 1626 1642 ) { 1627 - for arg in args { 1628 - if let Some(annotation) = &arg.annotation { 1643 + for argument in arguments { 1644 + if let Some(annotation) = &argument.annotation { 1629 1645 self.visit_type_ast(annotation); 1630 1646 } 1631 1647 } 1632 1648 if let Some(return_) = return_annotation { 1633 1649 self.visit_type_ast(return_); 1634 1650 } 1635 - ast::visit::visit_typed_expr_fn(self, location, type_, kind, args, body, return_annotation); 1651 + ast::visit::visit_typed_expr_fn( 1652 + self, 1653 + location, 1654 + type_, 1655 + kind, 1656 + arguments, 1657 + body, 1658 + return_annotation, 1659 + ); 1636 1660 } 1637 1661 1638 1662 fn visit_typed_function(&mut self, fun: &'ast ast::TypedFunction) { ··· 1857 1881 location: &'ast SrcSpan, 1858 1882 type_: &'ast Arc<Type>, 1859 1883 kind: &'ast FunctionLiteralKind, 1860 - args: &'ast [TypedArg], 1884 + arguments: &'ast [TypedArg], 1861 1885 body: &'ast Vec1<TypedStatement>, 1862 1886 return_annotation: &'ast Option<ast::TypeAst>, 1863 1887 ) { 1864 - for arg in args { 1865 - if let Some(annotation) = &arg.annotation { 1888 + for argument in arguments { 1889 + if let Some(annotation) = &argument.annotation { 1866 1890 self.visit_type_ast(annotation); 1867 1891 } 1868 1892 } 1869 1893 if let Some(return_) = return_annotation { 1870 1894 self.visit_type_ast(return_); 1871 1895 } 1872 - ast::visit::visit_typed_expr_fn(self, location, type_, kind, args, body, return_annotation); 1896 + ast::visit::visit_typed_expr_fn( 1897 + self, 1898 + location, 1899 + type_, 1900 + kind, 1901 + arguments, 1902 + body, 1903 + return_annotation, 1904 + ); 1873 1905 } 1874 1906 1875 1907 fn visit_typed_function(&mut self, fun: &'ast ast::TypedFunction) { ··· 2066 2098 location: &'ast SrcSpan, 2067 2099 type_: &'ast Arc<Type>, 2068 2100 kind: &'ast FunctionLiteralKind, 2069 - args: &'ast [TypedArg], 2101 + arguments: &'ast [TypedArg], 2070 2102 body: &'ast Vec1<TypedStatement>, 2071 2103 return_annotation: &'ast Option<ast::TypeAst>, 2072 2104 ) { 2073 - for arg in args { 2074 - if let Some(annotation) = &arg.annotation { 2105 + for argument in arguments { 2106 + if let Some(annotation) = &argument.annotation { 2075 2107 self.visit_type_ast(annotation); 2076 2108 } 2077 2109 } 2078 2110 if let Some(return_) = return_annotation { 2079 2111 self.visit_type_ast(return_); 2080 2112 } 2081 - ast::visit::visit_typed_expr_fn(self, location, type_, kind, args, body, return_annotation); 2113 + ast::visit::visit_typed_expr_fn( 2114 + self, 2115 + location, 2116 + type_, 2117 + kind, 2118 + arguments, 2119 + body, 2120 + return_annotation, 2121 + ); 2082 2122 } 2083 2123 2084 2124 fn visit_typed_function(&mut self, fun: &'ast ast::TypedFunction) { ··· 2228 2268 return vec![]; 2229 2269 }; 2230 2270 2231 - let TypedExpr::Call { args, fun, .. } = use_.call.as_ref() else { 2271 + let TypedExpr::Call { arguments, fun, .. } = use_.call.as_ref() else { 2232 2272 return vec![]; 2233 2273 }; 2234 2274 ··· 2244 2284 // list.fold(over: list, from: 1, with: fn(acc, item) { ... }) 2245 2285 // ^^^^^ We cannot forget to add this label back! 2246 2286 // 2247 - let callback_label = if args.iter().any(|arg| arg.label.is_some()) { 2287 + let callback_label = if arguments.iter().any(|arg| arg.label.is_some()) { 2248 2288 fun.field_map() 2249 - .and_then(|field_map| field_map.missing_labels(args).last().cloned()) 2289 + .and_then(|field_map| field_map.missing_labels(arguments).last().cloned()) 2250 2290 .map(|label| eco_format!("{label}: ")) 2251 2291 .unwrap_or(EcoString::from("")) 2252 2292 } else { ··· 2257 2297 // the following function: `wibble(a a, b b) { todo }` 2258 2298 // And use it like this: `use <- wibble(b: 1)`, the first argument `a` 2259 2299 // is going to be the use callback, not the last one! 2260 - let use_callback = args.iter().find(|arg| arg.is_use_implicit_callback()); 2300 + let use_callback = arguments.iter().find(|arg| arg.is_use_implicit_callback()); 2261 2301 let Some(CallArg { 2262 2302 implicit: Some(ImplicitCallArgOrigin::Use), 2263 2303 value: TypedExpr::Fn { body, type_, .. }, ··· 2288 2328 }); 2289 2329 2290 2330 let use_line_end = use_.right_hand_side_location.end; 2291 - let use_rhs_function_has_some_explicit_args = args 2331 + let use_rhs_function_has_some_explicit_arguments = arguments 2292 2332 .iter() 2293 - .filter(|arg| !arg.is_use_implicit_callback()) 2333 + .filter(|argument| !argument.is_use_implicit_callback()) 2294 2334 .peekable() 2295 2335 .peek() 2296 2336 .is_some(); ··· 2301 2341 .get(use_line_end as usize - 1..use_line_end as usize) 2302 2342 == Some(")"); 2303 2343 2304 - let last_explicit_arg = args.iter().filter(|arg| !arg.is_implicit()).next_back(); 2344 + let last_explicit_arg = arguments 2345 + .iter() 2346 + .filter(|argument| !argument.is_implicit()) 2347 + .next_back(); 2305 2348 let last_arg_end = last_explicit_arg.map_or(use_line_end - 1, |arg| arg.location.end); 2306 2349 2307 2350 // This is the piece of code between the end of the last argument and ··· 2338 2381 // If the function on the rhs of use has other orguments besides 2339 2382 // the implicit fn expression then we need to put a comma after 2340 2383 // the last argument. 2341 - if use_rhs_function_has_some_explicit_args && !use_rhs_has_comma_after_last_argument 2384 + if use_rhs_function_has_some_explicit_arguments 2385 + && !use_rhs_has_comma_after_last_argument 2342 2386 { 2343 2387 format!(", {callback_start}") 2344 2388 } else if needs_space_before_callback { ··· 2431 2475 struct CallLocations { 2432 2476 call_span: SrcSpan, 2433 2477 called_function_span: SrcSpan, 2434 - callback_args_span: Option<SrcSpan>, 2478 + callback_arguments_span: Option<SrcSpan>, 2435 2479 arg_before_callback_span: Option<SrcSpan>, 2436 2480 callback_body_span: SrcSpan, 2437 2481 } ··· 2456 2500 let Some(CallLocations { 2457 2501 call_span, 2458 2502 called_function_span, 2459 - callback_args_span, 2503 + callback_arguments_span, 2460 2504 arg_before_callback_span, 2461 2505 callback_body_span, 2462 2506 }) = self.selected_call ··· 2471 2515 2472 2516 // First we move the callback arguments to the left hand side of the 2473 2517 // call and add the `use` keyword. 2474 - let left_hand_side_text = if let Some(args_location) = callback_args_span { 2475 - let args_start = args_location.start as usize; 2476 - let args_end = args_location.end as usize; 2477 - let args_text = self.module.code.get(args_start..args_end).expect("fn args"); 2478 - format!("use {args_text} <- ") 2518 + let left_hand_side_text = if let Some(arguments_location) = callback_arguments_span { 2519 + let arguments_start = arguments_location.start as usize; 2520 + let arguments_end = arguments_location.end as usize; 2521 + let arguments_text = self 2522 + .module 2523 + .code 2524 + .get(arguments_start..arguments_end) 2525 + .expect("fn args"); 2526 + format!("use {arguments_text} <- ") 2479 2527 } else { 2480 2528 "use <- ".into() 2481 2529 }; ··· 2554 2602 location: &'ast SrcSpan, 2555 2603 type_: &'ast Arc<Type>, 2556 2604 kind: &'ast FunctionLiteralKind, 2557 - args: &'ast [TypedArg], 2605 + arguments: &'ast [TypedArg], 2558 2606 body: &'ast Vec1<TypedStatement>, 2559 2607 return_annotation: &'ast Option<ast::TypeAst>, 2560 2608 ) { ··· 2567 2615 } 2568 2616 } 2569 2617 2570 - ast::visit::visit_typed_expr_fn(self, location, type_, kind, args, body, return_annotation); 2618 + ast::visit::visit_typed_expr_fn( 2619 + self, 2620 + location, 2621 + type_, 2622 + kind, 2623 + arguments, 2624 + body, 2625 + return_annotation, 2626 + ); 2571 2627 } 2572 2628 2573 2629 fn visit_typed_expr_block( ··· 2602 2658 2603 2659 fn turn_expression_into_use(expr: &TypedExpr) -> Option<CallLocations> { 2604 2660 let TypedExpr::Call { 2605 - args, 2661 + arguments, 2606 2662 location: call_span, 2607 2663 fun: called_function, 2608 2664 .. ··· 2616 2672 // in which they are written by the user. Since the rest of the code relies 2617 2673 // on their order in the written code we first have to sort them by their 2618 2674 // source position. 2619 - let args = args 2675 + let arguments = arguments 2620 2676 .iter() 2621 - .sorted_by_key(|arg| arg.location.start) 2677 + .sorted_by_key(|argument| argument.location.start) 2622 2678 .collect_vec(); 2623 2679 2624 2680 let CallArg { 2625 2681 value: last_arg, 2626 2682 implicit: None, 2627 2683 .. 2628 - } = args.last()? 2684 + } = arguments.last()? 2629 2685 else { 2630 2686 return None; 2631 2687 }; 2632 2688 2633 2689 let TypedExpr::Fn { 2634 - args: callback_args, 2690 + arguments: callback_arguments, 2635 2691 body, 2636 2692 .. 2637 2693 } = last_arg ··· 2639 2695 return None; 2640 2696 }; 2641 2697 2642 - let callback_args_span = match (callback_args.first(), callback_args.last()) { 2698 + let callback_arguments_span = match (callback_arguments.first(), callback_arguments.last()) { 2643 2699 (Some(first), Some(last)) => Some(first.location.merge(&last.location)), 2644 2700 _ => None, 2645 2701 }; 2646 2702 2647 - let arg_before_callback_span = if args.len() >= 2 { 2648 - args.get(args.len() - 2).map(|call_arg| call_arg.location) 2703 + let arg_before_callback_span = if arguments.len() >= 2 { 2704 + arguments 2705 + .get(arguments.len() - 2) 2706 + .map(|call_arg| call_arg.location) 2649 2707 } else { 2650 2708 None 2651 2709 }; ··· 2655 2713 Some(CallLocations { 2656 2714 call_span: *call_span, 2657 2715 called_function_span: called_function.location(), 2658 - callback_args_span, 2716 + callback_arguments_span, 2659 2717 arg_before_callback_span, 2660 2718 callback_body_span, 2661 2719 }) ··· 3014 3072 location: &'ast SrcSpan, 3015 3073 type_: &'ast Arc<Type>, 3016 3074 kind: &'ast FunctionLiteralKind, 3017 - args: &'ast [TypedArg], 3075 + arguments: &'ast [TypedArg], 3018 3076 body: &'ast Vec1<TypedStatement>, 3019 3077 return_annotation: &'ast Option<ast::TypeAst>, 3020 3078 ) { ··· 3025 3083 location, 3026 3084 type_, 3027 3085 kind, 3028 - args, 3086 + arguments, 3029 3087 body, 3030 3088 return_annotation, 3031 3089 ); ··· 3047 3105 location, 3048 3106 type_, 3049 3107 kind, 3050 - args, 3108 + arguments, 3051 3109 body, 3052 3110 return_annotation, 3053 3111 ); ··· 3215 3273 } 3216 3274 3217 3275 // Extract record types as long as arguments can be constant 3218 - TypedExpr::Call { args, fun, .. } => { 3276 + TypedExpr::Call { arguments, fun, .. } => { 3219 3277 fun.is_record_builder() 3220 - && args 3278 + && arguments 3221 3279 .iter() 3222 3280 .all(|arg| can_be_constant(module, &arg.value, module_constants)) 3223 3281 } ··· 3537 3595 location: &'ast SrcSpan, 3538 3596 type_: &'ast Arc<Type>, 3539 3597 kind: &'ast FunctionLiteralKind, 3540 - args: &'ast [TypedArg], 3598 + arguments: &'ast [TypedArg], 3541 3599 body: &'ast Vec1<TypedStatement>, 3542 3600 return_annotation: &'ast Option<ast::TypeAst>, 3543 3601 ) { 3544 3602 let fn_range = self.edits.src_span_to_lsp_range(*location); 3545 3603 if within(self.params.range, fn_range) && kind.is_capture() { 3546 - if let [arg] = args { 3604 + if let [argument] = arguments { 3547 3605 self.function_capture_data = Some(FunctionCaptureData { 3548 3606 function_span: *location, 3549 - hole_span: arg.location, 3550 - hole_type: arg.type_.clone(), 3607 + hole_span: argument.location, 3608 + hole_type: argument.type_.clone(), 3551 3609 reserved_names: VariablesNames::from_statements(body), 3552 3610 }); 3553 3611 } 3554 3612 } 3555 3613 3556 - ast::visit::visit_typed_expr_fn(self, location, type_, kind, args, body, return_annotation) 3614 + ast::visit::visit_typed_expr_fn( 3615 + self, 3616 + location, 3617 + type_, 3618 + kind, 3619 + arguments, 3620 + body, 3621 + return_annotation, 3622 + ) 3557 3623 } 3558 3624 } 3559 3625 ··· 3751 3817 package: STDLIB_PACKAGE_NAME.into(), 3752 3818 module: DECODE_MODULE.into(), 3753 3819 name: "Decoder".into(), 3754 - args: vec![], 3820 + arguments: vec![], 3755 3821 inferred_variant: None, 3756 3822 }); 3757 3823 ··· 4148 4214 package: JSON_PACKAGE_NAME.into(), 4149 4215 module: JSON_MODULE.into(), 4150 4216 name: "Json".into(), 4151 - args: vec![], 4217 + arguments: vec![], 4152 4218 inferred_variant: None, 4153 4219 }); 4154 4220 ··· 4685 4751 } 4686 4752 4687 4753 pattern.push('('); 4688 - let args = (0..*constructor_arity as u32) 4754 + let arguments = (0..*constructor_arity as u32) 4689 4755 .map(|i| match index_to_label.get(&i) { 4690 4756 Some(label) => eco_format!("{label}:"), 4691 4757 None => match arguments_types.get(i as usize) { ··· 4695 4761 }) 4696 4762 .join(", "); 4697 4763 4698 - pattern.push_str(&args); 4764 + pattern.push_str(&arguments); 4699 4765 pattern.push(')'); 4700 4766 Some(pattern) 4701 4767 } ··· 4742 4808 location: &'ast SrcSpan, 4743 4809 type_: &'ast Arc<Type>, 4744 4810 kind: &'ast FunctionLiteralKind, 4745 - args: &'ast [TypedArg], 4811 + arguments: &'ast [TypedArg], 4746 4812 body: &'ast Vec1<TypedStatement>, 4747 4813 return_annotation: &'ast Option<ast::TypeAst>, 4748 4814 ) { ··· 4753 4819 return; 4754 4820 } 4755 4821 4756 - for arg in args { 4822 + for argument in arguments { 4757 4823 // If the cursor is placed on one of the arguments, then we can try 4758 4824 // and generate code for that one. 4759 - let arg_range = self.edits.src_span_to_lsp_range(arg.location); 4825 + let arg_range = self.edits.src_span_to_lsp_range(argument.location); 4760 4826 if within(self.params.range, arg_range) { 4761 4827 self.selected_value = Some(PatternMatchedValue::FunctionArgument { 4762 - arg, 4828 + arg: argument, 4763 4829 first_statement: body.first(), 4764 4830 function_range, 4765 4831 }); ··· 4770 4836 // If the cursor is not on any of the function arguments then we keep 4771 4837 // exploring the function body as we might want to destructure the 4772 4838 // argument of an expression function! 4773 - ast::visit::visit_typed_expr_fn(self, location, type_, kind, args, body, return_annotation); 4839 + ast::visit::visit_typed_expr_fn( 4840 + self, 4841 + location, 4842 + type_, 4843 + kind, 4844 + arguments, 4845 + body, 4846 + return_annotation, 4847 + ); 4774 4848 } 4775 4849 4776 4850 fn visit_typed_assignment(&mut self, assignment: &'ast TypedAssignment) { ··· 5071 5145 location: &'ast SrcSpan, 5072 5146 type_: &'ast Arc<Type>, 5073 5147 fun: &'ast TypedExpr, 5074 - args: &'ast [TypedCallArg], 5148 + arguments: &'ast [TypedCallArg], 5075 5149 ) { 5076 5150 // If the function being called is invalid we need to generate a 5077 5151 // function that has the proper labels. 5078 5152 let fun_range = self.edits.src_span_to_lsp_range(fun.location()); 5079 5153 5080 5154 if within(self.params.range, fun_range) && fun.is_invalid() { 5081 - if labels_are_correct(args) { 5082 - self.try_save_function_to_generate(fun.location(), &fun.type_(), Some(args)); 5155 + if labels_are_correct(arguments) { 5156 + self.try_save_function_to_generate(fun.location(), &fun.type_(), Some(arguments)); 5083 5157 } 5084 5158 } else { 5085 - ast::visit::visit_typed_expr_call(self, location, type_, fun, args); 5159 + ast::visit::visit_typed_expr_call(self, location, type_, fun, arguments); 5086 5160 } 5087 5161 } 5088 5162 } ··· 5167 5241 impl<'a> Arguments<'a> { 5168 5242 fn get(&self, index: usize) -> Option<Argument<'a>> { 5169 5243 match self { 5170 - Arguments::Patterns(call_args) => call_args.get(index).map(Argument::Pattern), 5171 - Arguments::Expressions(call_args) => call_args.get(index).map(Argument::Expression), 5244 + Arguments::Patterns(call_arguments) => call_arguments.get(index).map(Argument::Pattern), 5245 + Arguments::Expressions(call_arguments) => { 5246 + call_arguments.get(index).map(Argument::Expression) 5247 + } 5172 5248 } 5173 5249 } 5174 5250 5175 5251 fn types(&self) -> Vec<Arc<Type>> { 5176 5252 match self { 5177 - Arguments::Expressions(call_args) => call_args 5253 + Arguments::Expressions(call_arguments) => call_arguments 5178 5254 .iter() 5179 5255 .map(|argument| argument.value.type_()) 5180 5256 .collect_vec(), 5181 5257 5182 - Arguments::Patterns(call_args) => call_args 5258 + Arguments::Patterns(call_arguments) => call_arguments 5183 5259 .iter() 5184 5260 .map(|argument| argument.value.type_()) 5185 5261 .collect_vec(), ··· 5399 5475 location: &'ast SrcSpan, 5400 5476 type_: &'ast Arc<Type>, 5401 5477 fun: &'ast TypedExpr, 5402 - args: &'ast [TypedCallArg], 5478 + arguments: &'ast [TypedCallArg], 5403 5479 ) { 5404 5480 // If the function being called is invalid we need to generate a 5405 5481 // function that has the proper labels. 5406 5482 let fun_range = src_span_to_lsp_range(fun.location(), self.line_numbers); 5407 5483 if within(self.params.range, fun_range) && fun.is_invalid() { 5408 - if labels_are_correct(args) { 5484 + if labels_are_correct(arguments) { 5409 5485 self.try_save_variant_to_generate( 5410 5486 fun.location(), 5411 5487 &fun.type_(), 5412 - Some(Arguments::Expressions(args)), 5488 + Some(Arguments::Expressions(arguments)), 5413 5489 ); 5414 5490 } 5415 5491 } else { 5416 - ast::visit::visit_typed_expr_call(self, location, type_, fun, args); 5492 + ast::visit::visit_typed_expr_call(self, location, type_, fun, arguments); 5417 5493 } 5418 5494 } 5419 5495 ··· 5465 5541 #[must_use] 5466 5542 /// Checks the labels in the given arguments are correct: that is there's no 5467 5543 /// duplicate labels and all labelled arguments come after the unlabelled ones. 5468 - fn labels_are_correct<A>(args: &[CallArg<A>]) -> bool { 5544 + fn labels_are_correct<A>(arguments: &[CallArg<A>]) -> bool { 5469 5545 let mut labelled_arg_found = false; 5470 5546 let mut used_labels = HashSet::new(); 5471 5547 5472 - for arg in args { 5473 - match &arg.label { 5548 + for argument in arguments { 5549 + match &argument.label { 5474 5550 // Labels are invalid if there's duplicate ones or if an unlabelled 5475 5551 // argument comes after a labelled one. 5476 5552 Some(label) if used_labels.contains(label) => return false, ··· 6102 6178 location: &'ast SrcSpan, 6103 6179 _type_: &'ast Arc<Type>, 6104 6180 fun: &'ast TypedExpr, 6105 - args: &'ast [TypedCallArg], 6181 + arguments: &'ast [TypedCallArg], 6106 6182 ) { 6107 - if args.iter().any(|arg| arg.is_capture_hole()) { 6183 + if arguments.iter().any(|arg| arg.is_capture_hole()) { 6108 6184 return; 6109 6185 } 6110 6186 ··· 6114 6190 if self.visiting_use_call { 6115 6191 self.visiting_use_call = false; 6116 6192 ast::visit::visit_typed_expr(self, fun); 6117 - args.iter() 6193 + arguments 6194 + .iter() 6118 6195 .for_each(|arg| ast::visit::visit_typed_call_arg(self, arg)); 6119 6196 return; 6120 6197 } ··· 6136 6213 // // ^^^^^^^^^^^^^ pipe the first argument if I'm here 6137 6214 // // ^^^ pipe the second argument if I'm here 6138 6215 // ``` 6139 - let argument_to_pipe = args 6216 + let argument_to_pipe = arguments 6140 6217 .iter() 6141 6218 .enumerate() 6142 6219 .find_map(|(position, arg)| { ··· 6147 6224 None 6148 6225 } 6149 6226 }) 6150 - .or_else(|| args.first().map(|arg| (0, arg))); 6227 + .or_else(|| arguments.first().map(|argument| (0, argument))); 6151 6228 6152 6229 // If we're not hovering over any of the arguments _or_ there's no 6153 6230 // argument to extract at all we just return, there's nothing we can do ··· 6162 6239 call: *location, 6163 6240 position, 6164 6241 arg, 6165 - next_arg: args.get(position + 1).map(|arg| arg.location), 6242 + next_arg: arguments 6243 + .get(position + 1) 6244 + .map(|argument| argument.location), 6166 6245 }) 6167 6246 } 6168 6247 ··· 6451 6530 names.add_used_name(label.clone()); 6452 6531 } 6453 6532 6454 - let positional_args = positional 6533 + let positional_arguments = positional 6455 6534 .iter() 6456 6535 .map(|type_| names.generate_name_from_type(type_)) 6457 6536 .join(", "); ··· 6464 6543 // final positional argument we're adding to separate it from the ones that 6465 6544 // are going to come after. 6466 6545 let has_arguments_after = last_argument_end.is_some() || !labelled.is_empty(); 6467 - let positional_args = if has_arguments_after { 6468 - format!("{positional_args}, ") 6546 + let positional_arguments = if has_arguments_after { 6547 + format!("{positional_arguments}, ") 6469 6548 } else { 6470 - positional_args 6549 + positional_arguments 6471 6550 }; 6472 6551 6473 - self.edits.insert(insert_at, positional_args); 6552 + self.edits.insert(insert_at, positional_arguments); 6474 6553 } 6475 6554 6476 6555 if !labelled.is_empty() { 6477 6556 // If there's labelled arguments to add, we replace the existing spread 6478 6557 // with the arguments to be added. This way commas and all should already 6479 6558 // be correct. 6480 - let labelled_args = labelled 6559 + let labelled_arguments = labelled 6481 6560 .iter() 6482 6561 .map(|(label, _)| format!("{label}:")) 6483 6562 .join(", "); 6484 - self.edits.replace(spread_location, labelled_args); 6563 + self.edits.replace(spread_location, labelled_arguments); 6485 6564 } else if let Some(delete_start) = last_argument_end { 6486 6565 // However, if there's no labelled arguments to insert we still need 6487 6566 // to delete the entire spread: we start deleting from the end of the ··· 6693 6772 _location: &'ast SrcSpan, 6694 6773 _type_: &'ast Arc<Type>, 6695 6774 _kind: &'ast FunctionLiteralKind, 6696 - _args: &'ast [TypedArg], 6775 + _arguments: &'ast [TypedArg], 6697 6776 body: &'ast Vec1<TypedStatement>, 6698 6777 _return_annotation: &'ast Option<ast::TypeAst>, 6699 6778 ) {
+14 -13
compiler-core/src/language_server/completer.rs
··· 803 803 pub fn completion_labels( 804 804 &'a self, 805 805 fun: &TypedExpr, 806 - existing_args: &[CallArg<TypedExpr>], 806 + existing_arguments: &[CallArg<TypedExpr>], 807 807 ) -> Vec<CompletionItem> { 808 - let fun_type = fun.type_().fn_types().map(|(args, _)| args); 809 - let already_included_labels = existing_args 808 + let fun_type = fun.type_().fn_types().map(|(arguments, _)| arguments); 809 + let already_included_labels = existing_arguments 810 810 .iter() 811 811 .filter_map(|a| a.label.clone()) 812 812 .collect_vec(); ··· 821 821 .iter() 822 822 .filter(|field| !already_included_labels.contains(field.0)) 823 823 .map(|(label, arg_index)| { 824 - let detail = fun_type.as_ref().and_then(|args| { 825 - args.get(*arg_index as usize) 826 - .map(|a| Printer::new().pretty_print(a, 0)) 824 + let detail = fun_type.as_ref().and_then(|arguments| { 825 + arguments 826 + .get(*arg_index as usize) 827 + .map(|argument| Printer::new().pretty_print(argument, 0)) 827 828 }); 828 829 let label = format!("{label}:"); 829 830 let sort_text = Some(sort_text(CompletionKind::Label, &label)); ··· 1024 1025 fun: &'a Function<Arc<Type>, TypedExpr>, 1025 1026 ) -> Vec<CompletionItem> { 1026 1027 // Add function arguments to completions 1027 - self.visit_fn_args(&fun.arguments); 1028 + self.visit_fn_arguments(&fun.arguments); 1028 1029 1029 1030 // Visit the function body statements 1030 1031 for statement in &fun.body { ··· 1035 1036 self.completions.into_values().collect_vec() 1036 1037 } 1037 1038 1038 - fn visit_fn_args(&mut self, args: &[Arg<Arc<Type>>]) { 1039 - for arg in args { 1040 - if let Some(name) = arg.get_variable_name() { 1041 - self.push_completion(name, arg.type_.clone()); 1039 + fn visit_fn_arguments(&mut self, arguments: &[Arg<Arc<Type>>]) { 1040 + for argument in arguments { 1041 + if let Some(name) = argument.get_variable_name() { 1042 + self.push_completion(name, argument.type_.clone()); 1042 1043 } 1043 1044 } 1044 1045 } ··· 1084 1085 location: &'ast ast::SrcSpan, 1085 1086 _: &'ast Arc<Type>, 1086 1087 _: &'ast FunctionLiteralKind, 1087 - args: &'ast [ast::TypedArg], 1088 + arguments: &'ast [ast::TypedArg], 1088 1089 body: &'ast Vec1<ast::TypedStatement>, 1089 1090 _: &'ast Option<ast::TypeAst>, 1090 1091 ) { ··· 1093 1094 if self.cursor >= location.end { 1094 1095 return; 1095 1096 } 1096 - self.visit_fn_args(args); 1097 + self.visit_fn_arguments(arguments); 1097 1098 for statement in body { 1098 1099 self.visit_typed_statement(statement); 1099 1100 }
+7 -3
compiler-core/src/language_server/engine.rs
··· 293 293 } 294 294 | Located::Constant(Constant::String { .. }) => None, 295 295 Located::Expression { 296 - expression: TypedExpr::Call { fun, args, .. }, 296 + expression: TypedExpr::Call { fun, arguments, .. }, 297 297 .. 298 298 } => { 299 299 let mut completions = vec![]; 300 300 completions.append(&mut completer.completion_values()); 301 - completions.append(&mut completer.completion_labels(fun, args)); 301 + completions.append(&mut completer.completion_labels(fun, arguments)); 302 302 Some(completions) 303 303 } 304 304 Located::Expression { ··· 1193 1193 1194 1194 fn get_function_type(fun: &TypedFunction) -> Type { 1195 1195 Type::Fn { 1196 - args: fun.arguments.iter().map(|arg| arg.type_.clone()).collect(), 1196 + arguments: fun 1197 + .arguments 1198 + .iter() 1199 + .map(|argument| argument.type_.clone()) 1200 + .collect(), 1197 1201 return_: fun.return_type.clone(), 1198 1202 } 1199 1203 }
+28 -28
compiler-core/src/language_server/signature_help.rs
··· 17 17 pub fn for_expression(expr: &TypedExpr) -> Option<SignatureHelp> { 18 18 // If we're inside a function call we can provide signature help, 19 19 // otherwise we don't want anything to pop up. 20 - let TypedExpr::Call { fun, args, .. } = expr else { 20 + let TypedExpr::Call { fun, arguments, .. } = expr else { 21 21 return None; 22 22 }; 23 23 ··· 27 27 // help. 28 28 TypedExpr::Var { 29 29 constructor, name, .. 30 - } => signature_help(name.clone(), fun, args, constructor.field_map()), 30 + } => signature_help(name.clone(), fun, arguments, constructor.field_map()), 31 31 32 32 // If we're making a qualified call to another module's function 33 33 // then we want to show its type, documentation and the exact name ··· 50 50 | ModuleValueConstructor::Fn { field_map, .. } => field_map.into(), 51 51 }; 52 52 let name = format!("{module_alias}.{label}").into(); 53 - signature_help(name, fun, args, field_map) 53 + signature_help(name, fun, arguments, field_map) 54 54 } 55 55 56 56 // If the function bein called is an invalid node we don't want to ··· 67 67 // ^ When the cursor is here we are going to show 68 68 // "fn(a: a) -> a" as the help signature. 69 69 // 70 - _ => signature_help("fn".into(), fun, args, None), 70 + _ => signature_help("fn".into(), fun, arguments, None), 71 71 } 72 72 } 73 73 ··· 77 77 /// 78 78 /// - `fun_name` is used as the display name of the function in the help 79 79 /// signature. 80 - /// - `supplied_args` are arguments being passed to the function call, those 80 + /// - `supplied_arguments` are arguments being passed to the function call, those 81 81 /// might not be of the correct arity or have wrong types but are used to 82 82 /// deduce which argument should be highlighted next in the help signature. 83 83 /// - `field_map` is the function's field map (if any) that will be used to ··· 87 87 fn signature_help( 88 88 fun_name: EcoString, 89 89 fun: &TypedExpr, 90 - supplied_args: &[CallArg<TypedExpr>], 90 + supplied_arguments: &[CallArg<TypedExpr>], 91 91 field_map: Option<&FieldMap>, 92 92 ) -> Option<SignatureHelp> { 93 - let (args, return_) = fun.type_().fn_types()?; 93 + let (arguments, return_) = fun.type_().fn_types()?; 94 94 95 95 // If the function has no arguments, we don't want to show any help. 96 - let arity = args.len() as u32; 96 + let arity = arguments.len() as u32; 97 97 if arity == 0 { 98 98 return None; 99 99 } ··· 109 109 110 110 let printer = Printer::new(); 111 111 let (label, parameters) = 112 - print_signature_help(printer, fun_name, args, return_, &index_to_label); 112 + print_signature_help(printer, fun_name, arguments, return_, &index_to_label); 113 113 114 - let active_parameter = active_parameter_index(arity, supplied_args, index_to_label) 114 + let active_parameter = active_parameter_index(arity, supplied_arguments, index_to_label) 115 115 // If we don't want to highlight any arg in the suggestion we have to 116 116 // explicitly provide an out of bound index. 117 117 .or(Some(arity)); ··· 135 135 136 136 fn active_parameter_index( 137 137 arity: u32, 138 - supplied_args: &[CallArg<TypedExpr>], 138 + supplied_arguments: &[CallArg<TypedExpr>], 139 139 mut index_to_label: HashMap<u32, &EcoString>, 140 140 ) -> Option<u32> { 141 141 let mut is_use_call = false; 142 - let mut found_labelled_arg = false; 142 + let mut found_labelled_argument = false; 143 143 let mut used_labels = HashSet::new(); 144 144 145 - let mut supplied_unlabelled_args = 0; 146 - let unlabelled_args = arity - index_to_label.len() as u32; 145 + let mut supplied_unlabelled_arguments = 0; 146 + let unlabelled_arguments = arity - index_to_label.len() as u32; 147 147 148 - for (i, arg) in supplied_args.iter().enumerate() { 148 + for (i, arg) in supplied_arguments.iter().enumerate() { 149 149 // If there's an unlabelled argument after a labelled one, we can't 150 150 // figure out what to suggest since arguments were passed in a wrong 151 151 // order. 152 - if found_labelled_arg && arg.label.is_none() && !arg.is_implicit() { 152 + if found_labelled_argument && arg.label.is_none() && !arg.is_implicit() { 153 153 return None; 154 154 } 155 155 ··· 166 166 167 167 match &arg.label { 168 168 Some(label) => { 169 - found_labelled_arg = true; 169 + found_labelled_argument = true; 170 170 let _ = used_labels.insert(label); 171 171 } 172 172 ··· 174 174 // corresponding to it from the field map since it has already been 175 175 // passed as an unlabelled argument. 176 176 None => { 177 - supplied_unlabelled_args += 1; 177 + supplied_unlabelled_arguments += 1; 178 178 let _ = index_to_label.remove(&(i as u32)); 179 179 } 180 180 } 181 181 } 182 182 183 - let active_index = if supplied_unlabelled_args < unlabelled_args { 184 - if found_labelled_arg { 183 + let active_index = if supplied_unlabelled_arguments < unlabelled_arguments { 184 + if found_labelled_argument { 185 185 // If I have supplied some labelled args but I haven't supplied all 186 186 // unlabelled args before a labelled one then we can't safely 187 187 // suggest anything as the next argument. ··· 189 189 } else { 190 190 // If I haven't supplied enough unlabelled arguments then I have to 191 191 // set the next one as active (be it labelled or not). 192 - Some(supplied_unlabelled_args) 192 + Some(supplied_unlabelled_arguments) 193 193 } 194 194 } else { 195 195 // If I have supplied all the unlabelled arguments (and we could have ··· 200 200 .filter(|(_index, label)| !used_labels.contains(label)) 201 201 .map(|(index, _label)| index) 202 202 .min() 203 - .or(Some(supplied_args.len() as u32)) 203 + .or(Some(supplied_arguments.len() as u32)) 204 204 }; 205 205 206 206 // If we're showing hints for a use call and we end up deciding that the ··· 222 222 fn print_signature_help( 223 223 mut printer: Printer, 224 224 function_name: EcoString, 225 - args: Vec<Arc<Type>>, 225 + arguments: Vec<Arc<Type>>, 226 226 return_: Arc<Type>, 227 227 index_to_label: &HashMap<u32, &EcoString>, 228 228 ) -> (String, Vec<ParameterInformation>) { 229 - let args_count = args.len(); 229 + let arguments_count = arguments.len(); 230 230 let mut signature = format!("{function_name}("); 231 - let mut parameter_informations = Vec::with_capacity(args_count); 231 + let mut parameter_informations = Vec::with_capacity(arguments_count); 232 232 233 - for (i, arg) in args.iter().enumerate() { 233 + for (i, argument) in arguments.iter().enumerate() { 234 234 let arg_start = signature.len(); 235 235 if let Some(label) = index_to_label.get(&(i as u32)) { 236 236 signature.push_str(label); 237 237 signature.push_str(": "); 238 238 } 239 - signature.push_str(&printer.pretty_print(arg, 0)); 239 + signature.push_str(&printer.pretty_print(argument, 0)); 240 240 let arg_end = signature.len(); 241 241 let label = ParameterLabel::LabelOffsets([arg_start as u32, arg_end as u32]); 242 242 ··· 245 245 documentation: None, 246 246 }); 247 247 248 - let is_last = i == args_count - 1; 248 + let is_last = i == arguments_count - 1; 249 249 if !is_last { 250 250 signature.push_str(", "); 251 251 }
+6 -6
compiler-core/src/metadata/module_decoder.rs
··· 221 221 let package = self.string(reader.get_package()?)?; 222 222 let module = self.string(reader.get_module()?)?; 223 223 let name = self.string(reader.get_name()?)?; 224 - let args = read_vec!(&reader.get_parameters()?, self, type_); 224 + let arguments = read_vec!(&reader.get_parameters()?, self, type_); 225 225 let inferred_variant = self.inferred_variant(&reader.get_inferred_variant()?)?; 226 226 227 227 Ok(Arc::new(Type::Named { ··· 229 229 package, 230 230 module, 231 231 name, 232 - args, 232 + arguments, 233 233 inferred_variant, 234 234 })) 235 235 } 236 236 237 237 fn type_fn(&mut self, reader: &schema::type_::fn_::Reader<'_>) -> Result<Arc<Type>> { 238 238 let return_ = self.type_(&reader.get_return()?)?; 239 - let args = read_vec!(&reader.get_arguments()?, self, type_); 240 - Ok(Arc::new(Type::Fn { args, return_ })) 239 + let arguments = read_vec!(&reader.get_arguments()?, self, type_); 240 + Ok(Arc::new(Type::Fn { arguments, return_ })) 241 241 } 242 242 243 243 fn type_tuple(&mut self, reader: &schema::type_::tuple::Reader<'_>) -> Result<Arc<Type>> { ··· 423 423 fn constant_record(&mut self, reader: &constant::record::Reader<'_>) -> Result<TypedConstant> { 424 424 let type_ = self.type_(&reader.get_type()?)?; 425 425 let tag = self.string(reader.get_tag()?)?; 426 - let args = read_vec!(reader.get_args()?, self, constant_call_arg); 426 + let arguments = read_vec!(reader.get_args()?, self, constant_call_arg); 427 427 Ok(Constant::Record { 428 428 location: Default::default(), 429 429 module: Default::default(), 430 430 name: Default::default(), 431 - args, 431 + arguments, 432 432 tag, 433 433 type_, 434 434 field_map: None,
+17 -8
compiler-core/src/metadata/module_encoder.rs
··· 518 518 } 519 519 520 520 Constant::Record { 521 - args, tag, type_, .. 521 + arguments, 522 + tag, 523 + type_, 524 + .. 522 525 } => { 523 526 let mut builder = builder.init_record(); 524 527 { 525 - let mut builder = builder.reborrow().init_args(args.len() as u32); 526 - for (i, arg) in args.iter().enumerate() { 527 - self.build_constant(builder.reborrow().get(i as u32), &arg.value); 528 + let mut builder = builder.reborrow().init_args(arguments.len() as u32); 529 + for (i, argument) in arguments.iter().enumerate() { 530 + self.build_constant(builder.reborrow().get(i as u32), &argument.value); 528 531 } 529 532 } 530 533 builder.reborrow().set_tag(tag); ··· 632 635 633 636 fn build_type(&mut self, builder: schema::type_::Builder<'_>, type_: &Type) { 634 637 match type_ { 635 - Type::Fn { args, return_ } => { 638 + Type::Fn { arguments, return_ } => { 636 639 let mut fun = builder.init_fn(); 637 - self.build_types(fun.reborrow().init_arguments(args.len() as u32), args); 640 + self.build_types( 641 + fun.reborrow().init_arguments(arguments.len() as u32), 642 + arguments, 643 + ); 638 644 self.build_type(fun.init_return(), return_) 639 645 } 640 646 641 647 Type::Named { 642 648 name, 643 - args, 649 + arguments, 644 650 module, 645 651 package, 646 652 inferred_variant, ··· 655 661 Some(variant) => variant_builder.set_inferred(*variant), 656 662 None => variant_builder.set_unknown(()), 657 663 } 658 - self.build_types(app.reborrow().init_parameters(args.len() as u32), args); 664 + self.build_types( 665 + app.reborrow().init_parameters(arguments.len() as u32), 666 + arguments, 667 + ); 659 668 } 660 669 661 670 Type::Tuple { elements } => self.build_types(
+2 -2
compiler-core/src/metadata/tests.rs
··· 1111 1111 location: Default::default(), 1112 1112 module: None, 1113 1113 name: "".into(), 1114 - args: vec![ 1114 + arguments: vec![ 1115 1115 CallArg { 1116 1116 implicit: None, 1117 1117 label: None, ··· 1725 1725 package: "some_package".into(), 1726 1726 module: "the/module".into(), 1727 1727 name: "Wibble".into(), 1728 - args: Vec::new(), 1728 + arguments: Vec::new(), 1729 1729 inferred_variant: Some(1), 1730 1730 }), 1731 1731 publicity: Publicity::Public,
+7 -7
compiler-core/src/package_interface.rs
··· 472 472 match (value.type_.as_ref(), value.variant.clone()) { 473 473 ( 474 474 Type::Fn { 475 - args: arguments, 475 + arguments, 476 476 return_: return_type, 477 477 }, 478 478 ValueConstructorVariant::ModuleFn { ··· 559 559 /// have the same id will also have the same incremental number in the end). 560 560 fn from_type_helper(type_: &Type, id_map: &mut IdMap) -> TypeInterface { 561 561 match type_ { 562 - Type::Fn { args, return_ } => TypeInterface::Fn { 563 - parameters: args 562 + Type::Fn { arguments, return_ } => TypeInterface::Fn { 563 + parameters: arguments 564 564 .iter() 565 - .map(|arg| from_type_helper(arg.as_ref(), id_map)) 565 + .map(|argument| from_type_helper(argument.as_ref(), id_map)) 566 566 .collect(), 567 567 return_: Box::new(from_type_helper(return_, id_map)), 568 568 }, ··· 601 601 Type::Named { 602 602 name, 603 603 module, 604 - args, 604 + arguments, 605 605 package, 606 606 .. 607 607 } => TypeInterface::Named { 608 608 name: name.clone(), 609 609 package: package.clone(), 610 610 module: module.clone(), 611 - parameters: args 611 + parameters: arguments 612 612 .iter() 613 - .map(|arg| from_type_helper(arg.as_ref(), id_map)) 613 + .map(|argument| from_type_helper(argument.as_ref(), id_map)) 614 614 .collect(), 615 615 }, 616 616 }
+45 -43
compiler-core/src/parse.rs
··· 728 728 match self.parse_function(start, false, true, &mut attributes)? { 729 729 Some(Definition::Function(Function { 730 730 location, 731 - arguments: args, 731 + arguments, 732 732 body, 733 733 return_annotation, 734 734 end_position, ··· 737 737 location: SrcSpan::new(location.start, end_position), 738 738 end_of_head_byte_index: location.end, 739 739 kind: FunctionLiteralKind::Anonymous { head: location }, 740 - arguments: args, 740 + arguments, 741 741 body, 742 742 return_annotation, 743 743 }, ··· 941 941 end: base_e, 942 942 }, 943 943 }; 944 - let mut args = vec![]; 944 + let mut arguments = vec![]; 945 945 if self.maybe_one(&Token::Comma).is_some() { 946 - args = Parser::series_of( 946 + arguments = Parser::series_of( 947 947 self, 948 948 &Parser::parse_record_update_arg, 949 949 Some(&Token::Comma), ··· 955 955 location: SrcSpan { start, end }, 956 956 constructor: Box::new(expr), 957 957 record, 958 - arguments: args, 958 + arguments, 959 959 }; 960 960 } 961 961 _ => { 962 962 // Call 963 - let args = self.parse_fn_args()?; 963 + let arguments = self.parse_fn_arguments()?; 964 964 let (_, end) = self.expect_one(&Token::RightParen)?; 965 - expr = make_call(expr, args, start, end)?; 965 + expr = make_call(expr, arguments, start, end)?; 966 966 } 967 967 } 968 968 } else { ··· 1675 1675 fn parse_function_call_in_clause_guard(&mut self, start: u32) -> Result<(), ParseError> { 1676 1676 if let Some((l_paren_start, l_paren_end)) = self.maybe_one(&Token::LeftParen) { 1677 1677 if let Ok((_, end)) = self 1678 - .parse_fn_args() 1678 + .parse_fn_arguments() 1679 1679 .and(self.expect_one(&Token::RightParen)) 1680 1680 { 1681 1681 return parse_error(ParseErrorType::CallInClauseGuard, SrcSpan { start, end }); ··· 1861 1861 ) -> Result<UntypedPattern, ParseError> { 1862 1862 let (name_start, name, name_end) = self.expect_upname()?; 1863 1863 let mut start = name_start; 1864 - let (args, spread, end) = self.parse_constructor_pattern_args(name_end, position)?; 1864 + let (arguments, spread, end) = 1865 + self.parse_constructor_pattern_arguments(name_end, position)?; 1865 1866 if let Some((s, _, _)) = module { 1866 1867 start = s; 1867 1868 } 1868 1869 Ok(Pattern::Constructor { 1869 1870 location: SrcSpan { start, end }, 1870 1871 name_location: SrcSpan::new(name_start, name_end), 1871 - arguments: args, 1872 + arguments, 1872 1873 module: module.map(|(start, n, end)| (n, SrcSpan { start, end })), 1873 1874 name, 1874 1875 spread, ··· 1880 1881 // examples: 1881 1882 // ( args ) 1882 1883 #[allow(clippy::type_complexity)] 1883 - fn parse_constructor_pattern_args( 1884 + fn parse_constructor_pattern_arguments( 1884 1885 &mut self, 1885 1886 upname_end: u32, 1886 1887 position: PatternPosition, 1887 1888 ) -> Result<(Vec<CallArg<UntypedPattern>>, Option<SrcSpan>, u32), ParseError> { 1888 1889 if self.maybe_one(&Token::LeftParen).is_some() { 1889 - let (args, args_end_with_comma) = self.series_of_has_trailing_separator( 1890 + let (arguments, arguments_end_with_comma) = self.series_of_has_trailing_separator( 1890 1891 &|this| this.parse_constructor_pattern_arg(position), 1891 1892 Some(&Token::Comma), 1892 1893 )?; ··· 1897 1898 1898 1899 if let Some(spread_location) = spread { 1899 1900 let _ = self.maybe_one(&Token::Comma); 1900 - if !args.is_empty() && !args_end_with_comma { 1901 + if !arguments.is_empty() && !arguments_end_with_comma { 1901 1902 self.warnings 1902 1903 .push(DeprecatedSyntaxWarning::DeprecatedRecordSpreadPattern { 1903 1904 location: spread_location, ··· 1905 1906 } 1906 1907 } 1907 1908 let (_, end) = self.expect_one(&Token::RightParen)?; 1908 - Ok((args, spread, end)) 1909 + Ok((arguments, spread, end)) 1909 1910 } else { 1910 1911 Ok((vec![], None, upname_end)) 1911 1912 } ··· 2039 2040 let _ = self 2040 2041 .expect_one(&Token::LeftParen) 2041 2042 .map_err(|e| self.add_anon_function_hint(e))?; 2042 - let args = Parser::series_of( 2043 + let arguments = Parser::series_of( 2043 2044 self, 2044 2045 &|parser| Parser::parse_fn_param(parser, is_anon), 2045 2046 Some(&Token::Comma), ··· 2094 2095 end_position, 2095 2096 publicity: self.publicity(public, attributes.internal)?, 2096 2097 name, 2097 - arguments: args, 2098 + arguments, 2098 2099 body, 2099 2100 return_type: (), 2100 2101 return_annotation, ··· 2263 2264 // expr, expr 2264 2265 // a: _, expr 2265 2266 // a: expr, _, b: _ 2266 - fn parse_fn_args(&mut self) -> Result<Vec<ParserArg>, ParseError> { 2267 - let args = Parser::series_of(self, &Parser::parse_fn_arg, Some(&Token::Comma))?; 2268 - Ok(args) 2267 + fn parse_fn_arguments(&mut self) -> Result<Vec<ParserArg>, ParseError> { 2268 + let arguments = Parser::series_of(self, &Parser::parse_fn_argument, Some(&Token::Comma))?; 2269 + Ok(arguments) 2269 2270 } 2270 2271 2271 2272 // Parse a single function call arg ··· 2275 2276 // expr 2276 2277 // a: _ 2277 2278 // a: expr 2278 - fn parse_fn_arg(&mut self) -> Result<Option<ParserArg>, ParseError> { 2279 + fn parse_fn_argument(&mut self) -> Result<Option<ParserArg>, ParseError> { 2279 2280 let label = match (self.tok0.take(), self.tok1.take()) { 2280 2281 (Some((start, Token::Name { name }, _)), Some((_, Token::Colon, end))) => { 2281 2282 self.advance(); ··· 2409 2410 match Parser::maybe_upname(p) { 2410 2411 Some((c_s, c_n, c_e)) => { 2411 2412 let documentation = p.take_documentation(c_s); 2412 - let (args, args_e) = Parser::parse_type_constructor_args(p)?; 2413 - let end = args_e.max(c_e); 2413 + let (arguments, arguments_e) = 2414 + Parser::parse_type_constructor_arguments(p)?; 2415 + let end = arguments_e.max(c_e); 2414 2416 Ok(Some(RecordConstructor { 2415 2417 location: SrcSpan { start: c_s, end }, 2416 2418 name_location: SrcSpan { ··· 2418 2420 end: c_e, 2419 2421 }, 2420 2422 name: c_n, 2421 - arguments: args, 2423 + arguments, 2422 2424 documentation, 2423 2425 deprecation: attributes.deprecated, 2424 2426 })) ··· 2493 2495 let (start, upname, end) = self.expect_upname()?; 2494 2496 match self.maybe_one(&Token::LeftParen) { 2495 2497 Some((par_s, _)) => { 2496 - let args = 2498 + let arguments = 2497 2499 Parser::series_of(self, &|p| Ok(Parser::maybe_name(p)), Some(&Token::Comma))?; 2498 2500 let (_, par_e) = self.expect_one_following_series(&Token::RightParen, "a name")?; 2499 - if args.is_empty() { 2501 + if arguments.is_empty() { 2500 2502 return parse_error( 2501 2503 ParseErrorType::TypeDefinitionNoArguments, 2502 2504 SrcSpan::new(par_s, par_e), 2503 2505 ); 2504 2506 } 2505 - let args2 = args 2507 + let arguments2 = arguments 2506 2508 .into_iter() 2507 2509 .map(|(start, name, end)| (SrcSpan { start, end }, name)) 2508 2510 .collect(); 2509 - Ok((start, upname, args2, par_e, end)) 2511 + Ok((start, upname, arguments2, par_e, end)) 2510 2512 } 2511 2513 _ => Ok((start, upname, vec![], end, end)), 2512 2514 } ··· 2516 2518 // *no args* 2517 2519 // () 2518 2520 // (a, b) 2519 - fn parse_type_constructor_args( 2521 + fn parse_type_constructor_arguments( 2520 2522 &mut self, 2521 2523 ) -> Result<(Vec<RecordConstructorArg<()>>, u32), ParseError> { 2522 2524 if self.maybe_one(&Token::LeftParen).is_some() { 2523 - let args = Parser::series_of( 2525 + let arguments = Parser::series_of( 2524 2526 self, 2525 2527 &|p| match (p.tok0.take(), p.tok1.take()) { 2526 2528 ( ··· 2572 2574 )?; 2573 2575 let (_, end) = self 2574 2576 .expect_one_following_series(&Token::RightParen, "a constructor argument name")?; 2575 - Ok((args, end)) 2577 + Ok((arguments, end)) 2576 2578 } else { 2577 2579 Ok((vec![], 0)) 2578 2580 } ··· 2626 2628 Some((start, Token::Fn, _)) => { 2627 2629 self.advance(); 2628 2630 let _ = self.expect_one(&Token::LeftParen)?; 2629 - let args = 2631 + let arguments = 2630 2632 Parser::series_of(self, &|x| Parser::parse_type(x), Some(&Token::Comma))?; 2631 2633 let _ = self.expect_one_following_series(&Token::RightParen, "a type")?; 2632 2634 let (arr_s, arr_e) = self.expect_one(&Token::RArrow)?; ··· 2638 2640 end: return_.location().end, 2639 2641 }, 2640 2642 return_: Box::new(return_), 2641 - arguments: args, 2643 + arguments, 2642 2644 }))), 2643 2645 _ => parse_error( 2644 2646 ParseErrorType::ExpectedType, ··· 2694 2696 ) -> Result<Option<TypeAst>, ParseError> { 2695 2697 match self.maybe_one(&Token::LeftParen) { 2696 2698 Some((par_s, _)) => { 2697 - let args = self.parse_types()?; 2699 + let arguments = self.parse_types()?; 2698 2700 let (_, par_e) = self.expect_one(&Token::RightParen)?; 2699 - if args.is_empty() { 2701 + if arguments.is_empty() { 2700 2702 return parse_error( 2701 2703 ParseErrorType::TypeConstructorNoArguments, 2702 2704 SrcSpan::new(par_s, par_e), ··· 2710 2712 }, 2711 2713 module, 2712 2714 name, 2713 - arguments: args, 2715 + arguments, 2714 2716 }))) 2715 2717 } 2716 2718 _ => Ok(Some(TypeAst::Constructor(TypeAstConstructor { ··· 3195 3197 ) -> Result<Option<UntypedConstant>, ParseError> { 3196 3198 match self.maybe_one(&Token::LeftParen) { 3197 3199 Some((par_s, _)) => { 3198 - let args = 3200 + let arguments = 3199 3201 Parser::series_of(self, &Parser::parse_const_record_arg, Some(&Token::Comma))?; 3200 3202 let (_, par_e) = self.expect_one_following_series( 3201 3203 &Token::RightParen, 3202 3204 "a constant record argument", 3203 3205 )?; 3204 - if args.is_empty() { 3206 + if arguments.is_empty() { 3205 3207 return parse_error( 3206 3208 ParseErrorType::ConstantRecordConstructorNoArguments, 3207 3209 SrcSpan::new(par_s, par_e), ··· 3211 3213 location: SrcSpan { start, end: par_e }, 3212 3214 module, 3213 3215 name, 3214 - args, 3216 + arguments, 3215 3217 tag: (), 3216 3218 type_: (), 3217 3219 field_map: None, ··· 3222 3224 location: SrcSpan { start, end }, 3223 3225 module, 3224 3226 name, 3225 - args: vec![], 3227 + arguments: vec![], 3226 3228 tag: (), 3227 3229 type_: (), 3228 3230 field_map: None, ··· 4476 4478 4477 4479 pub fn make_call( 4478 4480 fun: UntypedExpr, 4479 - args: Vec<ParserArg>, 4481 + arguments: Vec<ParserArg>, 4480 4482 start: u32, 4481 4483 end: u32, 4482 4484 ) -> Result<UntypedExpr, ParseError> { 4483 4485 let mut hole_location = None; 4484 4486 4485 - let args = args 4487 + let arguments = arguments 4486 4488 .into_iter() 4487 - .map(|a| match a { 4489 + .map(|argument| match argument { 4488 4490 ParserArg::Arg(arg) => Ok(*arg), 4489 4491 ParserArg::Hole { 4490 4492 arg_location, ··· 4524 4526 let call = UntypedExpr::Call { 4525 4527 location: SrcSpan { start, end }, 4526 4528 fun: Box::new(fun), 4527 - arguments: args, 4529 + arguments, 4528 4530 }; 4529 4531 4530 4532 match hole_location {
+2 -2
compiler-core/src/pretty/tests.rs
··· 247 247 ]) 248 248 .group(); 249 249 250 - let args_doc = concat([ 250 + let arguments_doc = concat([ 251 251 break_("", ""), 252 252 "one".to_doc(), 253 253 ",".to_doc(), ··· 259 259 260 260 let function_call_doc = concat([ 261 261 "some_function_call(".to_doc(), 262 - args_doc, 262 + arguments_doc, 263 263 break_("", ""), 264 264 ")".to_doc(), 265 265 ])
+91 -64
compiler-core/src/type_.rs
··· 64 64 package: EcoString, 65 65 module: EcoString, 66 66 name: EcoString, 67 - args: Vec<Arc<Type>>, 67 + arguments: Vec<Arc<Type>>, 68 68 69 69 /// Which variant of the types this value is, if it is known from variant inference. 70 70 /// This allows us to permit certain operations when we know this, ··· 98 98 /// The type of a function. It takes arguments and returns a value. 99 99 /// 100 100 Fn { 101 - args: Vec<Arc<Type>>, 101 + arguments: Vec<Arc<Type>>, 102 102 return_: Arc<Type>, 103 103 }, 104 104 ··· 133 133 pub fn result_ok_type(&self) -> Option<Arc<Type>> { 134 134 match self { 135 135 Self::Named { 136 - module, name, args, .. 137 - } if "Result" == name && is_prelude_module(module) => args.first().cloned(), 136 + module, 137 + name, 138 + arguments, 139 + .. 140 + } if "Result" == name && is_prelude_module(module) => arguments.first().cloned(), 138 141 Self::Var { type_ } => type_.borrow().result_ok_type(), 139 142 Self::Named { .. } | Self::Tuple { .. } | Type::Fn { .. } => None, 140 143 } ··· 143 146 pub fn result_types(&self) -> Option<(Arc<Type>, Arc<Type>)> { 144 147 match self { 145 148 Self::Named { 146 - module, name, args, .. 149 + module, 150 + name, 151 + arguments, 152 + .. 147 153 } if "Result" == name && is_prelude_module(module) => { 148 - Some((args.first().cloned()?, args.get(1).cloned()?)) 154 + Some((arguments.first().cloned()?, arguments.get(1).cloned()?)) 149 155 } 150 156 Self::Var { type_ } => type_.borrow().result_types(), 151 157 Self::Named { .. } | Self::Tuple { .. } | Type::Fn { .. } => None, ··· 176 182 177 183 pub fn fn_types(&self) -> Option<(Vec<Arc<Self>>, Arc<Self>)> { 178 184 match self { 179 - Self::Fn { args, return_, .. } => Some((args.clone(), return_.clone())), 185 + Self::Fn { 186 + arguments, return_, .. 187 + } => Some((arguments.clone(), return_.clone())), 180 188 Self::Var { type_ } => type_.borrow().fn_types(), 181 189 _ => None, 182 190 } ··· 195 203 /// does not lead to a type constructor. 196 204 pub fn constructor_types(&self) -> Option<Vec<Arc<Self>>> { 197 205 match self { 198 - Self::Named { args, .. } => Some(args.clone()), 206 + Self::Named { arguments, .. } => Some(arguments.clone()), 199 207 Self::Var { type_, .. } => type_.borrow().constructor_types(), 200 208 _ => None, 201 209 } ··· 210 218 name, 211 219 module, 212 220 package, 213 - args, 221 + arguments, 214 222 inferred_variant: _, 215 223 } if package == PRELUDE_PACKAGE_NAME 216 224 && module == PRELUDE_MODULE_NAME 217 225 && name == LIST => 218 226 { 219 - match args.as_slice() { 227 + match arguments.as_slice() { 220 228 [inner_type] => Some(inner_type.clone()), 221 229 [] | [_, _, ..] => None, 222 230 } ··· 231 239 package: PRELUDE_PACKAGE_NAME.into(), 232 240 module: PRELUDE_MODULE_NAME.into(), 233 241 name: LIST.into(), 234 - args: vec![inner_type], 242 + arguments: vec![inner_type], 235 243 inferred_variant: None, 236 244 } 237 245 } ··· 322 330 pub fn named_type_information(&self) -> Option<(EcoString, EcoString, Vec<Arc<Self>>)> { 323 331 match self { 324 332 Self::Named { 325 - module, name, args, .. 326 - } => Some((module.clone(), name.clone(), args.clone())), 333 + module, 334 + name, 335 + arguments, 336 + .. 337 + } => Some((module.clone(), name.clone(), arguments.clone())), 327 338 Self::Var { type_ } => type_.borrow().named_type_information(), 328 339 _ => None, 329 340 } ··· 350 361 Arc::make_mut(element).generalise_custom_type_variant(); 351 362 } 352 363 } 353 - Type::Fn { args, return_ } => { 354 - for argument in args { 364 + Type::Fn { arguments, return_ } => { 365 + for argument in arguments { 355 366 Arc::make_mut(argument).generalise_custom_type_variant(); 356 367 } 357 368 Arc::make_mut(return_).generalise_custom_type_variant(); ··· 375 386 /// This function is currently only used for finding the `List` type. 376 387 /// 377 388 // TODO: specialise this to just List. 378 - pub fn get_app_args( 389 + pub fn get_app_arguments( 379 390 &self, 380 391 publicity: Publicity, 381 392 package: &str, ··· 388 399 Self::Named { 389 400 module: m, 390 401 name: n, 391 - args, 402 + arguments, 392 403 .. 393 404 } => { 394 - if module == m && name == n && args.len() == arity { 395 - Some(args.clone()) 405 + if module == m && name == n && arguments.len() == arity { 406 + Some(arguments.clone()) 396 407 } else { 397 408 None 398 409 } 399 410 } 400 411 401 412 Self::Var { type_ } => { 402 - let args: Vec<_> = match type_.borrow().deref() { 413 + let arguments: Vec<_> = match type_.borrow().deref() { 403 414 TypeVar::Link { type_ } => { 404 - return type_.get_app_args( 415 + return type_.get_app_arguments( 405 416 publicity, 406 417 package, 407 418 module, ··· 425 436 name: name.into(), 426 437 package: package.into(), 427 438 module: module.into(), 428 - args: args.clone(), 439 + arguments: arguments.clone(), 429 440 publicity, 430 441 inferred_variant: None, 431 442 }), 432 443 }; 433 - Some(args) 444 + Some(arguments) 434 445 } 435 446 436 447 _ => None, ··· 444 455 .. 445 456 } => Some(self.clone()), 446 457 447 - Self::Named { args, .. } => args.iter().find_map(|type_| type_.find_private_type()), 458 + Self::Named { arguments, .. } => { 459 + arguments.iter().find_map(|type_| type_.find_private_type()) 460 + } 448 461 449 462 Self::Tuple { elements, .. } => { 450 463 elements.iter().find_map(|type_| type_.find_private_type()) 451 464 } 452 465 453 - Self::Fn { return_, args, .. } => return_ 466 + Self::Fn { 467 + return_, arguments, .. 468 + } => return_ 454 469 .find_private_type() 455 - .or_else(|| args.iter().find_map(|type_| type_.find_private_type())), 470 + .or_else(|| arguments.iter().find_map(|type_| type_.find_private_type())), 456 471 457 472 Self::Var { type_, .. } => match type_.borrow().deref() { 458 473 TypeVar::Unbound { .. } => None, ··· 468 483 match self { 469 484 Self::Named { publicity, .. } if publicity.is_internal() => Some(self.clone()), 470 485 471 - Self::Named { args, .. } => args.iter().find_map(|type_| type_.find_internal_type()), 486 + Self::Named { arguments, .. } => arguments 487 + .iter() 488 + .find_map(|type_| type_.find_internal_type()), 472 489 473 490 Self::Tuple { elements, .. } => { 474 491 elements.iter().find_map(|type_| type_.find_internal_type()) 475 492 } 476 493 477 - Self::Fn { return_, args, .. } => return_ 478 - .find_internal_type() 479 - .or_else(|| args.iter().find_map(|type_| type_.find_internal_type())), 494 + Self::Fn { 495 + return_, arguments, .. 496 + } => return_.find_internal_type().or_else(|| { 497 + arguments 498 + .iter() 499 + .find_map(|type_| type_.find_internal_type()) 500 + }), 480 501 481 502 Self::Var { type_, .. } => match type_.borrow().deref() { 482 503 TypeVar::Unbound { .. } | TypeVar::Generic { .. } => None, ··· 487 508 488 509 pub fn fn_arity(&self) -> Option<usize> { 489 510 match self { 490 - Self::Fn { args, .. } => Some(args.len()), 511 + Self::Fn { arguments, .. } => Some(arguments.len()), 491 512 _ => None, 492 513 } 493 514 } ··· 512 533 package, 513 534 module, 514 535 name, 515 - args, 536 + arguments, 516 537 inferred_variant: _, 517 538 }, 518 539 Type::Named { ··· 520 541 package: other_package, 521 542 module: other_module, 522 543 name: other_name, 523 - args: other_args, 544 + arguments: other_arguments, 524 545 inferred_variant: _, 525 546 }, 526 547 ) => { ··· 528 549 && package == other_package 529 550 && module == other_module 530 551 && name == other_name 531 - && args == other_args 552 + && arguments == other_arguments 532 553 } 533 554 534 555 (Type::Fn { .. }, Type::Named { .. } | Type::Tuple { .. }) => false, ··· 536 557 type_.as_ref().borrow().same_as_other_type(one) 537 558 } 538 559 ( 539 - Type::Fn { args, return_ }, 560 + Type::Fn { arguments, return_ }, 540 561 Type::Fn { 541 - args: other_args, 562 + arguments: other_arguments, 542 563 return_: other_return, 543 564 }, 544 565 ) => { 545 - args.len() == other_args.len() 546 - && args 566 + arguments.len() == other_arguments.len() 567 + && arguments 547 568 .iter() 548 - .zip(other_args) 569 + .zip(other_arguments) 549 570 .all(|(one, other)| one.same_as(other)) 550 571 && return_.same_as(other_return) 551 572 } ··· 1468 1489 1469 1490 pub type TypedCallArg = CallArg<TypedExpr>; 1470 1491 1471 - fn assert_no_labelled_arguments<A>(args: &[CallArg<A>]) -> Result<(), Error> { 1472 - for arg in args { 1473 - if let Some(label) = &arg.label { 1492 + fn assert_no_labelled_arguments<A>(arguments: &[CallArg<A>]) -> Result<(), Error> { 1493 + for argument in arguments { 1494 + if let Some(label) = &argument.label { 1474 1495 return Err(Error::UnexpectedLabelledArg { 1475 - location: arg.location, 1496 + location: argument.location, 1476 1497 label: label.clone(), 1477 1498 }); 1478 1499 } ··· 1509 1530 } 1510 1531 1511 1532 match type_.deref() { 1512 - Type::Named { args, .. } => { 1513 - for arg in args { 1514 - unify_unbound_type(arg.clone(), own_id)? 1533 + Type::Named { arguments, .. } => { 1534 + for argument in arguments { 1535 + unify_unbound_type(argument.clone(), own_id)? 1515 1536 } 1516 1537 Ok(()) 1517 1538 } 1518 1539 1519 - Type::Fn { args, return_ } => { 1520 - for arg in args { 1521 - unify_unbound_type(arg.clone(), own_id)?; 1540 + Type::Fn { arguments, return_ } => { 1541 + for argument in arguments { 1542 + unify_unbound_type(argument.clone(), own_id)?; 1522 1543 } 1523 1544 unify_unbound_type(return_.clone(), own_id) 1524 1545 } ··· 1546 1567 } 1547 1568 1548 1569 TypeVar::Unbound { .. } => { 1549 - let args: Vec<_> = (0..arity).map(|_| environment.new_unbound_var()).collect(); 1570 + let arguments: Vec<_> = (0..arity).map(|_| environment.new_unbound_var()).collect(); 1550 1571 let return_ = environment.new_unbound_var(); 1551 - Some((args, return_)) 1572 + Some((arguments, return_)) 1552 1573 } 1553 1574 1554 1575 TypeVar::Generic { .. } => None, 1555 1576 }; 1556 1577 1557 - if let Some((args, return_)) = new_value { 1578 + if let Some((arguments, return_)) = new_value { 1558 1579 *type_.borrow_mut() = TypeVar::Link { 1559 - type_: fn_(args.clone(), return_.clone()), 1580 + type_: fn_(arguments.clone(), return_.clone()), 1560 1581 }; 1561 - return Ok((args, return_)); 1582 + return Ok((arguments, return_)); 1562 1583 } 1563 1584 } 1564 1585 1565 - if let Type::Fn { args, return_ } = type_.deref() { 1566 - return if args.len() != arity { 1586 + if let Type::Fn { arguments, return_ } = type_.deref() { 1587 + return if arguments.len() != arity { 1567 1588 Err(MatchFunTypeError::IncorrectArity { 1568 - expected: args.len(), 1589 + expected: arguments.len(), 1569 1590 given: arity, 1570 - args: args.clone(), 1591 + arguments: arguments.clone(), 1571 1592 return_type: return_.clone(), 1572 1593 }) 1573 1594 } else { 1574 - Ok((args.clone(), return_.clone())) 1595 + Ok((arguments.clone(), return_.clone())) 1575 1596 }; 1576 1597 } 1577 1598 ··· 1593 1614 module, 1594 1615 package, 1595 1616 name, 1596 - args, 1617 + arguments, 1597 1618 inferred_variant: _, 1598 1619 } => { 1599 - let args = args.iter().map(|type_| generalise(type_.clone())).collect(); 1620 + let arguments = arguments 1621 + .iter() 1622 + .map(|type_| generalise(type_.clone())) 1623 + .collect(); 1600 1624 Arc::new(Type::Named { 1601 1625 publicity: *publicity, 1602 1626 module: module.clone(), 1603 1627 package: package.clone(), 1604 1628 name: name.clone(), 1605 - args, 1629 + arguments, 1606 1630 inferred_variant: None, 1607 1631 }) 1608 1632 } 1609 1633 1610 - Type::Fn { args, return_ } => fn_( 1611 - args.iter().map(|type_| generalise(type_.clone())).collect(), 1634 + Type::Fn { arguments, return_ } => fn_( 1635 + arguments 1636 + .iter() 1637 + .map(|type_| generalise(type_.clone())) 1638 + .collect(), 1612 1639 generalise(return_.clone()), 1613 1640 ), 1614 1641
+22 -14
compiler-core/src/type_/environment.rs
··· 555 555 name, 556 556 package, 557 557 module, 558 - args, 558 + arguments, 559 559 inferred_variant, 560 560 } => { 561 - let args = args 561 + let arguments = arguments 562 562 .iter() 563 563 .map(|type_| self.instantiate(type_.clone(), ids, hydrator)) 564 564 .collect(); ··· 567 567 name: name.clone(), 568 568 package: package.clone(), 569 569 module: module.clone(), 570 - args, 570 + arguments, 571 571 inferred_variant: *inferred_variant, 572 572 }) 573 573 } ··· 601 601 }) 602 602 } 603 603 604 - Type::Fn { args, return_, .. } => fn_( 605 - args.iter() 604 + Type::Fn { 605 + arguments, return_, .. 606 + } => fn_( 607 + arguments 608 + .iter() 606 609 .map(|type_| self.instantiate(type_.clone(), ids, hydrator)) 607 610 .collect(), 608 611 self.instantiate(return_.clone(), ids, hydrator), ··· 935 938 Type::Named { 936 939 module: m1, 937 940 name: n1, 938 - args: args1, 941 + arguments: arguments1, 939 942 .. 940 943 }, 941 944 Type::Named { 942 945 module: m2, 943 946 name: n2, 944 - args: args2, 947 + arguments: arguments2, 945 948 .. 946 949 }, 947 - ) if m1 == m2 && n1 == n2 && args1.len() == args2.len() => { 948 - for (a, b) in args1.iter().zip(args2) { 950 + ) if m1 == m2 && n1 == n2 && arguments1.len() == arguments2.len() => { 951 + for (a, b) in arguments1.iter().zip(arguments2) { 949 952 unify_enclosed_type(t1.clone(), t2.clone(), unify(a.clone(), b.clone()))?; 950 953 } 951 954 Ok(()) ··· 969 972 970 973 ( 971 974 Type::Fn { 972 - args: args1, 975 + arguments: arguments1, 973 976 return_: return1, 974 977 .. 975 978 }, 976 979 Type::Fn { 977 - args: args2, 980 + arguments: arguments2, 978 981 return_: return2, 979 982 .. 980 983 }, 981 984 ) => { 982 - if args1.len() != args2.len() { 983 - Err(unify_wrong_arity(&t1, args1.len(), &t2, args2.len()))? 985 + if arguments1.len() != arguments2.len() { 986 + Err(unify_wrong_arity( 987 + &t1, 988 + arguments1.len(), 989 + &t2, 990 + arguments2.len(), 991 + ))? 984 992 } 985 993 986 - for (i, (a, b)) in args1.iter().zip(args2).enumerate() { 994 + for (i, (a, b)) in arguments1.iter().zip(arguments2).enumerate() { 987 995 unify(a.clone(), b.clone()) 988 996 .map_err(|_| unify_wrong_arguments(&t1, a, &t2, b, i))?; 989 997 }
+3 -3
compiler-core/src/type_/error.rs
··· 956 956 TodoOrPanicUsedAsFunction { 957 957 kind: TodoOrPanic, 958 958 location: SrcSpan, 959 - args_location: Option<SrcSpan>, 960 - args: usize, 959 + arguments_location: Option<SrcSpan>, 960 + arguments: usize, 961 961 }, 962 962 963 963 UnreachableCodeAfterPanic { ··· 1430 1430 IncorrectArity { 1431 1431 expected: usize, 1432 1432 given: usize, 1433 - args: Vec<Arc<Type>>, 1433 + arguments: Vec<Arc<Type>>, 1434 1434 return_type: Arc<Type>, 1435 1435 }, 1436 1436 NotFn {
+138 -122
compiler-core/src/type_/expression.rs
··· 481 481 UntypedExpr::Fn { 482 482 location, 483 483 kind, 484 - arguments: args, 484 + arguments, 485 485 body, 486 486 return_annotation, 487 487 .. 488 - } => Ok(self.infer_fn(args, &[], body, kind, return_annotation, location)), 488 + } => Ok(self.infer_fn(arguments, &[], body, kind, return_annotation, location)), 489 489 490 490 UntypedExpr::Case { 491 491 location, ··· 503 503 UntypedExpr::Call { 504 504 location, 505 505 fun, 506 - arguments: args, 506 + arguments, 507 507 .. 508 - } => Ok(self.infer_call(*fun, args, location, CallKind::Function)), 508 + } => Ok(self.infer_call(*fun, arguments, location, CallKind::Function)), 509 509 510 510 UntypedExpr::BinOp { 511 511 location, ··· 543 543 location, 544 544 constructor, 545 545 record, 546 - arguments: args, 547 - } => self.infer_record_update(*constructor, record, args, location), 546 + arguments, 547 + } => self.infer_record_update(*constructor, record, arguments, location), 548 548 549 549 UntypedExpr::NegateBool { location, value } => { 550 550 Ok(self.infer_negate_bool(location, *value)) ··· 923 923 924 924 fn infer_fn( 925 925 &mut self, 926 - args: Vec<UntypedArg>, 927 - expected_args: &[Arc<Type>], 926 + arguments: Vec<UntypedArg>, 927 + expected_arguments: &[Arc<Type>], 928 928 body: Vec1<UntypedStatement>, 929 929 kind: FunctionLiteralKind, 930 930 return_annotation: Option<TypeAst>, 931 931 location: SrcSpan, 932 932 ) -> TypedExpr { 933 - for Arg { names, .. } in args.iter() { 933 + for Arg { names, .. } in arguments.iter() { 934 934 check_argument_names(names, self.problems); 935 935 } 936 936 ··· 961 961 // no way for a call to `divide_partial` to produce any side effects. 962 962 self.purity = Purity::Pure; 963 963 964 - let (args, body) = match self.do_infer_fn(args, expected_args, body, &return_annotation) { 965 - Ok(result) => result, 966 - Err(error) => { 967 - self.problems.error(error); 968 - return self.error_expr(location); 969 - } 970 - }; 971 - let args_types = args.iter().map(|a| a.type_.clone()).collect(); 972 - let type_ = fn_(args_types, body.last().type_()); 964 + let (arguments, body) = 965 + match self.do_infer_fn(arguments, expected_arguments, body, &return_annotation) { 966 + Ok(result) => result, 967 + Err(error) => { 968 + self.problems.error(error); 969 + return self.error_expr(location); 970 + } 971 + }; 972 + let arguments_types = arguments.iter().map(|a| a.type_.clone()).collect(); 973 + let type_ = fn_(arguments_types, body.last().type_()); 973 974 974 975 // Defining an anonymous function never panics. 975 976 self.already_warned_for_unreachable_code = already_warned_for_unreachable_code; ··· 982 983 location, 983 984 type_, 984 985 kind, 985 - args, 986 + arguments, 986 987 body, 987 988 return_annotation, 988 989 purity: function_purity, ··· 1035 1036 fn infer_call( 1036 1037 &mut self, 1037 1038 fun: UntypedExpr, 1038 - args: Vec<CallArg<UntypedExpr>>, 1039 + arguments: Vec<CallArg<UntypedExpr>>, 1039 1040 location: SrcSpan, 1040 1041 kind: CallKind, 1041 1042 ) -> TypedExpr { 1042 - let (fun, args, type_) = self.do_infer_call(fun, args, location, kind); 1043 + let (fun, arguments, type_) = self.do_infer_call(fun, arguments, location, kind); 1043 1044 1044 1045 // One common mistake is to think that the syntax for adding a message 1045 1046 // to a `todo` or a `panic` exception is to `todo("...")`, but really ··· 1052 1053 _ => None, 1053 1054 }; 1054 1055 if let Some((location, kind)) = todopanic { 1055 - let args_location = match (args.first(), args.last()) { 1056 + let arguments_location = match (arguments.first(), arguments.last()) { 1056 1057 (Some(first), Some(last)) => Some(SrcSpan { 1057 1058 start: first.location().start, 1058 1059 end: last.location().end, ··· 1062 1063 self.problems.warning(Warning::TodoOrPanicUsedAsFunction { 1063 1064 kind, 1064 1065 location, 1065 - args_location, 1066 - args: args.len(), 1066 + arguments_location, 1067 + arguments: arguments.len(), 1067 1068 }); 1068 1069 } 1069 1070 ··· 1072 1073 TypedExpr::Call { 1073 1074 location, 1074 1075 type_, 1075 - args, 1076 + arguments, 1076 1077 fun: Box::new(fun), 1077 1078 } 1078 1079 } ··· 2974 2975 &mut self, 2975 2976 constructor: UntypedExpr, 2976 2977 record: RecordBeingUpdated, 2977 - args: Vec<UntypedRecordUpdateArg>, 2978 + arguments: Vec<UntypedRecordUpdateArg>, 2978 2979 location: SrcSpan, 2979 2980 ) -> Result<TypedExpr, Error> { 2980 2981 // infer the constructor being used ··· 3052 3053 let variant = 3053 3054 self.infer_record_update_variant(&typed_constructor, &value_constructor, &record_var)?; 3054 3055 3055 - let args = self.infer_record_update_args(&variant, &record_var, args, location)?; 3056 + let arguments = 3057 + self.infer_record_update_arguments(&variant, &record_var, arguments, location)?; 3056 3058 3057 3059 Ok(TypedExpr::RecordUpdate { 3058 3060 location, 3059 3061 type_: variant.retn, 3060 3062 record_assignment, 3061 3063 constructor: Box::new(typed_constructor), 3062 - args, 3064 + arguments, 3063 3065 }) 3064 3066 } 3065 3067 3066 - fn infer_record_update_args( 3068 + fn infer_record_update_arguments( 3067 3069 &mut self, 3068 3070 variant: &RecordUpdateVariant<'_>, 3069 3071 record: &TypedExpr, 3070 - args: Vec<UntypedRecordUpdateArg>, 3072 + arguments: Vec<UntypedRecordUpdateArg>, 3071 3073 location: SrcSpan, 3072 3074 ) -> Result<Vec<TypedCallArg>, Error> { 3073 3075 let record_location = record.location(); ··· 3078 3080 let mut fields = variant.fields.clone(); 3079 3081 3080 3082 // collect explicit arguments given in the record update 3081 - let explicit_args = args 3083 + let explicit_arguments = arguments 3082 3084 .iter() 3083 3085 .map( 3084 3086 |arg @ UntypedRecordUpdateArg { ··· 3145 3147 _ => convert_unify_error(e, record_location), 3146 3148 }; 3147 3149 3148 - let implicit_args = fields 3150 + let implicit_arguments = fields 3149 3151 .into_iter() 3150 3152 .map(|(label, index)| { 3151 3153 let record_access = self.infer_known_record_expression_access( ··· 3172 3174 }) 3173 3175 .collect::<Result<Vec<_>, _>>()?; 3174 3176 3175 - if explicit_args.is_empty() { 3177 + if explicit_arguments.is_empty() { 3176 3178 self.problems 3177 3179 .warning(Warning::NoFieldsRecordUpdate { location }); 3178 3180 } 3179 3181 3180 - if implicit_args.is_empty() { 3182 + if implicit_arguments.is_empty() { 3181 3183 self.problems 3182 3184 .warning(Warning::AllFieldsRecordUpdate { location }); 3183 3185 } 3184 3186 3185 - let args = explicit_args 3187 + let arguments = explicit_arguments 3186 3188 .into_iter() 3187 - .chain(implicit_args) 3189 + .chain(implicit_arguments) 3188 3190 .sorted_by_key(|(index, _)| *index) 3189 3191 .map(|(_, value)| value) 3190 3192 .collect(); 3191 3193 3192 - Ok(args) 3194 + Ok(arguments) 3193 3195 } 3194 3196 3195 3197 fn infer_record_update_variant<'c>( ··· 3200 3202 ) -> Result<RecordUpdateVariant<'c>, Error> { 3201 3203 let record_type = record.type_(); 3202 3204 // The record constructor needs to be a function. 3203 - let (args_types, return_type) = match constructor.type_().as_ref() { 3204 - Type::Fn { args, return_ } => (args.clone(), return_.clone()), 3205 + let (arguments_types, return_type) = match constructor.type_().as_ref() { 3206 + Type::Fn { arguments, return_ } => (arguments.clone(), return_.clone()), 3205 3207 _ => { 3206 3208 return Err(Error::RecordUpdateInvalidConstructor { 3207 3209 location: constructor.location(), ··· 3244 3246 // Updating a record with only one variant is always safe 3245 3247 if variants_count == 1 { 3246 3248 return Ok(RecordUpdateVariant { 3247 - args: args_types, 3249 + arguments: arguments_types, 3248 3250 retn: return_type, 3249 3251 fields: &field_map.fields, 3250 3252 }); ··· 3255 3257 if record_index.is_some_and(|index| index == variant_index) { 3256 3258 self.track_feature_usage(FeatureKind::RecordUpdateVariantInference, record.location()); 3257 3259 return Ok(RecordUpdateVariant { 3258 - args: args_types, 3260 + arguments: arguments_types, 3259 3261 retn: return_type, 3260 3262 fields: &field_map.fields, 3261 3263 }); ··· 3578 3580 module, 3579 3581 location, 3580 3582 name, 3581 - args, 3583 + arguments, 3582 3584 // field_map, is always None here because untyped not yet unified 3583 3585 .. 3584 - } if args.is_empty() => { 3586 + } if arguments.is_empty() => { 3585 3587 // Type check the record constructor 3586 3588 let constructor = self.infer_value_constructor(&module, &name, &location)?; 3587 3589 ··· 3606 3608 module, 3607 3609 location, 3608 3610 name, 3609 - args: vec![], 3611 + arguments: vec![], 3610 3612 type_: constructor.type_.clone(), 3611 3613 tag, 3612 3614 field_map, ··· 3618 3620 module, 3619 3621 location, 3620 3622 name, 3621 - mut args, 3623 + mut arguments, 3622 3624 // field_map, is always None here because untyped not yet unified 3623 3625 .. 3624 3626 } => { ··· 3665 3667 name: name.clone(), 3666 3668 variant_index, 3667 3669 field_map: field_map.clone(), 3668 - arity: args.len() as u16, 3670 + arity: arguments.len() as u16, 3669 3671 type_: Arc::clone(&type_), 3670 3672 location: constructor.variant.definition_location(), 3671 3673 documentation: None, ··· 3698 3700 .map_err(|e| convert_get_value_constructor_error(e, location, None))? 3699 3701 { 3700 3702 // The fun has a field map so labelled arguments may be present and need to be reordered. 3701 - Some(field_map) => { 3702 - field_map.reorder(&mut args, location, IncorrectArityContext::Function)? 3703 - } 3703 + Some(field_map) => field_map.reorder( 3704 + &mut arguments, 3705 + location, 3706 + IncorrectArityContext::Function, 3707 + )?, 3704 3708 3705 3709 // The fun has no field map and so we error if arguments have been labelled 3706 - None => assert_no_labelled_arguments(&args)?, 3710 + None => assert_no_labelled_arguments(&arguments)?, 3707 3711 } 3708 3712 3709 - let (mut args_types, return_type) = 3710 - match_fun_type(fun.type_(), args.len(), self.environment).map_err(|e| { 3711 - convert_not_fun_error(e, fun.location(), location, CallKind::Function) 3712 - })?; 3713 + let (mut arguments_types, return_type) = match_fun_type( 3714 + fun.type_(), 3715 + arguments.len(), 3716 + self.environment, 3717 + ) 3718 + .map_err(|error| { 3719 + convert_not_fun_error(error, fun.location(), location, CallKind::Function) 3720 + })?; 3713 3721 3714 - let args = args_types 3722 + let arguments = arguments_types 3715 3723 .iter_mut() 3716 - .zip(args) 3717 - .map(|(type_, arg): (&mut Arc<Type>, _)| { 3718 - if arg.uses_label_shorthand() { 3724 + .zip(arguments) 3725 + .map(|(type_, argument): (&mut Arc<Type>, _)| { 3726 + if argument.uses_label_shorthand() { 3719 3727 self.track_feature_usage( 3720 3728 FeatureKind::LabelShorthandSyntax, 3721 - arg.location, 3729 + argument.location, 3722 3730 ); 3723 3731 } 3724 3732 let CallArg { ··· 3726 3734 value, 3727 3735 location, 3728 3736 implicit, 3729 - } = arg; 3737 + } = argument; 3730 3738 let value = self.infer_const(&None, value); 3731 3739 unify(type_.clone(), value.type_()) 3732 - .map_err(|e| convert_unify_error(e, value.location()))?; 3740 + .map_err(|error| convert_unify_error(error, value.location()))?; 3733 3741 Ok(CallArg { 3734 3742 label, 3735 3743 value, ··· 3743 3751 module, 3744 3752 location, 3745 3753 name, 3746 - args, 3754 + arguments, 3747 3755 type_: return_type, 3748 3756 tag, 3749 3757 field_map, ··· 3930 3938 pub fn do_infer_call( 3931 3939 &mut self, 3932 3940 fun: UntypedExpr, 3933 - args: Vec<CallArg<UntypedExpr>>, 3941 + arguments: Vec<CallArg<UntypedExpr>>, 3934 3942 location: SrcSpan, 3935 3943 kind: CallKind, 3936 3944 ) -> (TypedExpr, Vec<TypedCallArg>, Arc<Type>) { ··· 3951 3959 UntypedExpr::Fn { 3952 3960 location, 3953 3961 kind, 3954 - arguments, 3962 + arguments: fn_arguments, 3955 3963 body, 3956 3964 return_annotation, 3957 3965 .. 3958 - } if arguments.len() == args.len() => self.infer_fn_with_call_context( 3959 - arguments, 3960 - &args, 3966 + } if fn_arguments.len() == arguments.len() => self.infer_fn_with_call_context( 3967 + fn_arguments, 3968 + &arguments, 3961 3969 body, 3962 3970 kind, 3963 3971 return_annotation, ··· 3967 3975 fun => self.infer(fun), 3968 3976 }; 3969 3977 3970 - let (fun, args, type_) = self.do_infer_call_with_known_fun(fun, args, location, kind); 3971 - (fun, args, type_) 3978 + let (fun, arguments, type_) = 3979 + self.do_infer_call_with_known_fun(fun, arguments, location, kind); 3980 + (fun, arguments, type_) 3972 3981 } 3973 3982 3974 3983 fn infer_fn_with_call_context( 3975 3984 &mut self, 3976 - args: Vec<UntypedArg>, 3977 - call_args: &[CallArg<UntypedExpr>], 3985 + arguments: Vec<UntypedArg>, 3986 + call_arguments: &[CallArg<UntypedExpr>], 3978 3987 body: Vec1<UntypedStatement>, 3979 3988 kind: FunctionLiteralKind, 3980 3989 return_annotation: Option<TypeAst>, 3981 3990 location: SrcSpan, 3982 3991 ) -> TypedExpr { 3983 - let typed_call_args: Vec<Arc<Type>> = call_args 3992 + let typed_call_arguments: Vec<Arc<Type>> = call_arguments 3984 3993 .iter() 3985 - .map(|a| { 3986 - match self.infer_or_error(a.value.clone()) { 3987 - Ok(arg) => arg, 3994 + .map(|argument| { 3995 + match self.infer_or_error(argument.value.clone()) { 3996 + Ok(argument) => argument, 3988 3997 Err(_e) => self.error_expr(location), 3989 3998 } 3990 3999 .type_() 3991 4000 }) 3992 4001 .collect_vec(); 3993 4002 self.infer_fn( 3994 - args, 3995 - &typed_call_args, 4003 + arguments, 4004 + &typed_call_arguments, 3996 4005 body, 3997 4006 kind, 3998 4007 return_annotation, ··· 4003 4012 pub fn do_infer_call_with_known_fun( 4004 4013 &mut self, 4005 4014 fun: TypedExpr, 4006 - mut args: Vec<CallArg<UntypedExpr>>, 4015 + mut arguments: Vec<CallArg<UntypedExpr>>, 4007 4016 location: SrcSpan, 4008 4017 kind: CallKind, 4009 4018 ) -> (TypedExpr, Vec<TypedCallArg>, Arc<Type>) { ··· 4017 4026 // The fun has a field map so labelled arguments may be 4018 4027 // present and need to be reordered. 4019 4028 Some(field_map) => { 4020 - field_map.reorder(&mut args, location, IncorrectArityContext::Function) 4029 + field_map.reorder(&mut arguments, location, IncorrectArityContext::Function) 4021 4030 } 4022 4031 4023 4032 // The fun has no field map and so we error if arguments ··· 4029 4038 // known to be a valid function we can make sure that there's 4030 4039 // no labelled arguments if it doesn't actually have a field map. 4031 4040 None if fun.is_invalid() => Ok(()), 4032 - None => assert_no_labelled_arguments(&args), 4041 + None => assert_no_labelled_arguments(&arguments), 4033 4042 } 4034 4043 }); 4035 4044 ··· 4057 4066 } 4058 4067 } 4059 4068 4060 - let mut missing_args = 0; 4061 - let mut ignored_labelled_args = vec![]; 4069 + let mut missing_arguments = 0; 4070 + let mut ignored_labelled_arguments = vec![]; 4062 4071 // Extract the type of the fun, ensuring it actually is a function 4063 - let (mut args_types, return_type) = 4064 - match match_fun_type(fun.type_(), args.len(), self.environment) { 4072 + let (mut arguments_types, return_type) = 4073 + match match_fun_type(fun.type_(), arguments.len(), self.environment) { 4065 4074 Ok(fun) => fun, 4066 4075 Err(e) => { 4067 4076 let converted_error = ··· 4070 4079 // If the function was valid but had the wrong number of arguments passed. 4071 4080 // Then we keep the error but still want to continue analysing the arguments that were passed. 4072 4081 MatchFunTypeError::IncorrectArity { 4073 - args: arg_types, 4082 + arguments: arg_types, 4074 4083 return_type, 4075 4084 expected, 4076 4085 given, 4077 4086 .. 4078 4087 } => { 4079 - missing_args = expected.saturating_sub(given); 4088 + missing_arguments = expected.saturating_sub(given); 4080 4089 // If the function has labels then arity issues will already 4081 4090 // be handled by the field map so we can ignore them here. 4082 4091 if !labelled_arity_error { ··· 4086 4095 // Since arity errors with labels cause incorrect 4087 4096 // ordering, we can't type check the labelled arguments here. 4088 4097 let first_labelled_arg = 4089 - args.iter().position(|arg| arg.label.is_some()); 4090 - ignored_labelled_args = args 4098 + arguments.iter().position(|arg| arg.label.is_some()); 4099 + ignored_labelled_arguments = arguments 4091 4100 .iter() 4092 - .skip_while(|arg| arg.label.is_none()) 4093 - .map(|arg| (arg.label.clone(), arg.location, arg.implicit)) 4101 + .skip_while(|argument| argument.label.is_none()) 4102 + .map(|argument| { 4103 + ( 4104 + argument.label.clone(), 4105 + argument.location, 4106 + argument.implicit, 4107 + ) 4108 + }) 4094 4109 .collect_vec(); 4095 - let args_to_keep = first_labelled_arg.unwrap_or(args.len()); 4110 + let arguments_to_keep = 4111 + first_labelled_arg.unwrap_or(arguments.len()); 4096 4112 ( 4097 - arg_types.iter().take(args_to_keep).cloned().collect(), 4113 + arg_types.iter().take(arguments_to_keep).cloned().collect(), 4098 4114 return_type, 4099 4115 ) 4100 4116 } ··· 4120 4136 // This way we can provide better argument hints for incomplete use 4121 4137 // expressions. 4122 4138 if let CallKind::Use { .. } = kind { 4123 - if let Some(last) = args.pop() { 4124 - for _ in 0..missing_args { 4125 - args.push(CallArg { 4139 + if let Some(last) = arguments.pop() { 4140 + for _ in 0..missing_arguments { 4141 + arguments.push(CallArg { 4126 4142 label: None, 4127 4143 location, 4128 4144 value: UntypedExpr::Placeholder { ··· 4137 4153 implicit: Some(ImplicitCallArgOrigin::IncorrectArityUse), 4138 4154 }); 4139 4155 } 4140 - args.push(last); 4156 + arguments.push(last); 4141 4157 } 4142 4158 }; 4143 4159 4144 4160 // Ensure that the given args have the correct types 4145 - let args_count = args_types.len(); 4146 - let mut typed_args: Vec<_> = args_types 4161 + let arguments_count = arguments_types.len(); 4162 + let mut typed_arguments: Vec<_> = arguments_types 4147 4163 .iter_mut() 4148 - .zip(args) 4164 + .zip(arguments) 4149 4165 .enumerate() 4150 4166 .map(|(i, (type_, arg))| { 4151 4167 if arg.uses_label_shorthand() { ··· 4167 4183 call_location, 4168 4184 last_statement_location, 4169 4185 assignments_location, 4170 - } if i == args_count - 1 => ArgumentKind::UseCallback { 4186 + } if i == arguments_count - 1 => ArgumentKind::UseCallback { 4171 4187 function_location: call_location, 4172 4188 assignments_location, 4173 4189 last_statement_location, ··· 4203 4219 // 4204 4220 // So now what we want to do is add back those labelled arguments to 4205 4221 // make sure the LS can still see that those were explicitly supplied. 4206 - for (label, location, implicit) in ignored_labelled_args { 4207 - typed_args.push(CallArg { 4222 + for (label, location, implicit) in ignored_labelled_arguments { 4223 + typed_arguments.push(CallArg { 4208 4224 label, 4209 4225 value: TypedExpr::Invalid { 4210 4226 location, ··· 4222 4238 self.warn_for_unreachable_code(fun.location(), PanicPosition::LastFunctionArgument); 4223 4239 } 4224 4240 4225 - (fun, typed_args, return_type) 4241 + (fun, typed_arguments, return_type) 4226 4242 } 4227 4243 4228 4244 fn infer_call_argument( ··· 4242 4258 // messages. 4243 4259 ( 4244 4260 Type::Fn { 4245 - args: expected_arguments, 4261 + arguments: expected_arguments, 4246 4262 .. 4247 4263 }, 4248 4264 UntypedExpr::Fn { ··· 4276 4292 4277 4293 pub fn do_infer_fn( 4278 4294 &mut self, 4279 - args: Vec<UntypedArg>, 4280 - expected_args: &[Arc<Type>], 4295 + arguments: Vec<UntypedArg>, 4296 + expected_arguments: &[Arc<Type>], 4281 4297 body: Vec1<UntypedStatement>, 4282 4298 return_annotation: &Option<TypeAst>, 4283 4299 ) -> Result<(Vec<TypedArg>, Vec1<TypedStatement>), Error> { 4284 4300 // Construct an initial type for each argument of the function- either an unbound 4285 4301 // type variable or a type provided by an annotation. 4286 - let args: Vec<_> = args 4302 + let arguments: Vec<_> = arguments 4287 4303 .into_iter() 4288 4304 .enumerate() 4289 - .map(|(i, arg)| self.infer_arg(arg, expected_args.get(i).cloned())) 4305 + .map(|(i, argument)| self.infer_arg(argument, expected_arguments.get(i).cloned())) 4290 4306 .try_collect()?; 4291 4307 4292 4308 let return_type = match return_annotation { ··· 4294 4310 None => None, 4295 4311 }; 4296 4312 4297 - self.infer_fn_with_known_types(args, body, return_type) 4313 + self.infer_fn_with_known_types(arguments, body, return_type) 4298 4314 } 4299 4315 4300 4316 pub fn infer_fn_with_known_types( 4301 4317 &mut self, 4302 - args: Vec<TypedArg>, 4318 + arguments: Vec<TypedArg>, 4303 4319 body: Vec1<UntypedStatement>, 4304 4320 return_type: Option<Arc<Type>>, 4305 4321 ) -> Result<(Vec<TypedArg>, Vec1<TypedStatement>), Error> { ··· 4311 4327 4312 4328 self.in_new_scope(|body_typer| { 4313 4329 // Used to track if any argument names are used more than once 4314 - let mut argument_names = HashSet::with_capacity(args.len()); 4330 + let mut argument_names = HashSet::with_capacity(arguments.len()); 4315 4331 4316 - for arg in args.iter() { 4317 - match &arg.names { 4332 + for argument in arguments.iter() { 4333 + match &argument.names { 4318 4334 ArgNames::Named { name, location } 4319 4335 | ArgNames::NamedLabelled { 4320 4336 name, ··· 4325 4341 // another argument 4326 4342 if !argument_names.insert(name) { 4327 4343 return Err(Error::ArgumentNameAlreadyUsed { 4328 - location: arg.location, 4344 + location: argument.location, 4329 4345 name: name.clone(), 4330 4346 }); 4331 4347 } ··· 4346 4362 name.clone(), 4347 4363 *location, 4348 4364 origin.clone(), 4349 - arg.type_.clone(), 4365 + argument.type_.clone(), 4350 4366 ); 4351 4367 4352 4368 if !body.first().is_placeholder() { ··· 4355 4371 body_typer.environment.init_usage( 4356 4372 name.clone(), 4357 4373 origin, 4358 - arg.location, 4374 + argument.location, 4359 4375 body_typer.problems, 4360 4376 ); 4361 4377 } ··· 4392 4408 }; 4393 4409 } 4394 4410 4395 - Ok((args, body)) 4411 + Ok((arguments, body)) 4396 4412 }) 4397 4413 } 4398 4414 ··· 4781 4797 /// Used during `infer_record_update` to return information about the updated variant. 4782 4798 #[derive(Debug)] 4783 4799 struct RecordUpdateVariant<'a> { 4784 - args: Vec<Arc<Type>>, 4800 + arguments: Vec<Arc<Type>>, 4785 4801 retn: Arc<Type>, 4786 4802 fields: &'a HashMap<EcoString, u32>, 4787 4803 } 4788 4804 4789 4805 impl RecordUpdateVariant<'_> { 4790 4806 fn arg_type(&self, index: u32) -> Arc<Type> { 4791 - self.args 4807 + self.arguments 4792 4808 .get(index as usize) 4793 4809 .expect("Failed to get record argument type after successfully inferring that field") 4794 4810 .clone() ··· 4995 5011 ( 4996 5012 TypedExpr::Call { 4997 5013 fun: fun_one, 4998 - args: args_one, 5014 + arguments: arguments_one, 4999 5015 .. 5000 5016 }, 5001 5017 TypedExpr::Call { 5002 5018 fun: fun_other, 5003 - args: args_other, 5019 + arguments: arguments_other, 5004 5020 .. 5005 5021 }, 5006 5022 ) => match (fun_one.variant_index(), fun_other.variant_index()) { ··· 5017 5033 // Otherwise we need to check their arguments pairwise: 5018 5034 (Some(_), Some(_)) => { 5019 5035 let mut comparison = StaticComparison::CertainlyEqual; 5020 - for (one, other) in args_one.iter().zip(args_other.iter()) { 5036 + for (one, other) in arguments_one.iter().zip(arguments_other.iter()) { 5021 5037 match static_compare(&one.value, &other.value) { 5022 5038 StaticComparison::CertainlyEqual => (), 5023 5039 // If we can tell any of the arguments are never going to
+31 -31
compiler-core/src/type_/fields.rs
··· 44 44 /// 45 45 pub fn reorder<A>( 46 46 &self, 47 - args: &mut Vec<CallArg<A>>, 47 + arguments: &mut Vec<CallArg<A>>, 48 48 location: SrcSpan, 49 49 context: IncorrectArityContext, 50 50 ) -> Result<(), Error> { 51 51 let mut labelled_arguments_given = false; 52 52 let mut seen_labels = HashSet::new(); 53 53 let mut unknown_labels = Vec::new(); 54 - let number_of_arguments = args.len(); 54 + let number_of_arguments = arguments.len(); 55 55 56 - if self.arity as usize != args.len() { 56 + if self.arity as usize != arguments.len() { 57 57 return Err(Error::IncorrectArity { 58 - labels: self.missing_labels(args), 58 + labels: self.missing_labels(arguments), 59 59 location, 60 60 context, 61 61 expected: self.arity as usize, 62 - given: args.len(), 62 + given: arguments.len(), 63 63 }); 64 64 } 65 65 66 - for arg in args.iter() { 67 - match &arg.label { 66 + for argument in arguments.iter() { 67 + match &argument.label { 68 68 Some(_) => { 69 69 labelled_arguments_given = true; 70 70 } 71 71 72 72 None => { 73 - if labelled_arguments_given && !arg.is_implicit() { 73 + if labelled_arguments_given && !argument.is_implicit() { 74 74 return Err(Error::PositionalArgumentAfterLabelled { 75 - location: arg.location, 75 + location: argument.location, 76 76 }); 77 77 } 78 78 } ··· 85 85 // We iterate the argument in reverse order, because we have to remove elements 86 86 // from the `args` list quite a lot, and removing from the end of a list is more 87 87 // efficient than removing from the beginning or the middle. 88 - let mut i = args.len(); 88 + let mut i = arguments.len(); 89 89 while i > 0 { 90 90 i -= 1; 91 - let (label, &location) = match &args.get(i).expect("Field indexing to get label").label 92 - { 93 - // A labelled argument, we may need to reposition it 94 - Some(l) => ( 95 - l, 96 - &args 97 - .get(i) 98 - .expect("Indexing in labelled field reordering") 99 - .location, 100 - ), 91 + let (label, &location) = 92 + match &arguments.get(i).expect("Field indexing to get label").label { 93 + // A labelled argument, we may need to reposition it 94 + Some(l) => ( 95 + l, 96 + &arguments 97 + .get(i) 98 + .expect("Indexing in labelled field reordering") 99 + .location, 100 + ), 101 101 102 - // Not a labelled argument 103 - None => { 104 - continue; 105 - } 106 - }; 102 + // Not a labelled argument 103 + None => { 104 + continue; 105 + } 106 + }; 107 107 108 108 let position = match self.fields.get(label) { 109 109 None => { ··· 124 124 125 125 // Add this argument to the `labelled_arguments` map, and remove if from the 126 126 // existing arguments list. It will be reinserted later in the correct index 127 - let _ = labelled_arguments.insert(position as usize, args.remove(i)); 127 + let _ = labelled_arguments.insert(position as usize, arguments.remove(i)); 128 128 } 129 129 130 130 // The labelled arguments must be reinserted in order 131 131 for i in 0..number_of_arguments { 132 - if let Some(arg) = labelled_arguments.remove(&i) { 133 - args.insert(i, arg); 132 + if let Some(argument) = labelled_arguments.remove(&i) { 133 + arguments.insert(i, argument); 134 134 } 135 135 } 136 136 ··· 158 158 /// wibble(1, label3: 2) // -> unused labels: [label2] 159 159 /// ``` 160 160 /// 161 - pub fn missing_labels<A>(&self, args: &[CallArg<A>]) -> Vec<EcoString> { 161 + pub fn missing_labels<A>(&self, arguments: &[CallArg<A>]) -> Vec<EcoString> { 162 162 // We need to know how many positional arguments are in the function 163 163 // arguments. That's given by the position of the first labelled 164 164 // argument; if the first label argument is third, then we know the ··· 170 170 // We need to count how many positional arguments were actually supplied 171 171 // in the call, to remove the corresponding labelled arguments that have 172 172 // been taken by any positional argument. 173 - let given_positional_arguments = args 173 + let given_positional_arguments = arguments 174 174 .iter() 175 175 .filter(|argument| argument.label.is_none() && !argument.is_use_implicit_callback()) 176 176 .count(); 177 177 178 - let explicit_labels = args 178 + let explicit_labels = arguments 179 179 .iter() 180 180 .filter_map(|argument| argument.label.as_ref()) 181 181 .collect::<HashSet<&EcoString>>();
+10 -12
compiler-core/src/type_/hydrator.rs
··· 117 117 name_location, 118 118 module, 119 119 name, 120 - arguments: args, 120 + arguments, 121 121 }) => { 122 122 // Hydrate the type argument AST into types 123 - let mut argument_types = Vec::with_capacity(args.len()); 124 - for t in args { 125 - let type_ = self.type_from_ast(t, environment, problems)?; 126 - argument_types.push((t.location(), type_)); 123 + let mut argument_types = Vec::with_capacity(arguments.len()); 124 + for argument in arguments { 125 + let type_ = self.type_from_ast(argument, environment, problems)?; 126 + argument_types.push((argument.location(), type_)); 127 127 } 128 128 129 129 // Look up the constructor ··· 183 183 } 184 184 185 185 // Ensure that the correct number of arguments have been given to the constructor 186 - if args.len() != parameters.len() { 186 + if arguments.len() != parameters.len() { 187 187 return Err(Error::IncorrectTypeArity { 188 188 location: *location, 189 189 name: name.clone(), 190 190 expected: parameters.len(), 191 - given: args.len(), 191 + given: arguments.len(), 192 192 }); 193 193 } 194 194 ··· 221 221 )), 222 222 223 223 TypeAst::Fn(TypeAstFn { 224 - arguments: args, 225 - return_, 226 - .. 224 + arguments, return_, .. 227 225 }) => { 228 - let args = args 226 + let arguments = arguments 229 227 .iter() 230 228 .map(|type_| self.type_from_ast(type_, environment, problems)) 231 229 .try_collect()?; 232 230 let return_ = self.type_from_ast(return_, environment, problems)?; 233 - Ok(fn_(args, return_)) 231 + Ok(fn_(arguments, return_)) 234 232 } 235 233 236 234 TypeAst::Var(TypeAstVar { name, location }) => {
+32 -31
compiler-core/src/type_/pattern.rs
··· 752 752 elements, 753 753 tail, 754 754 .. 755 - } => match type_.get_app_args( 755 + } => match type_.get_app_arguments( 756 756 Publicity::Public, 757 757 PRELUDE_PACKAGE_NAME, 758 758 PRELUDE_MODULE_NAME, ··· 760 760 1, 761 761 self.environment, 762 762 ) { 763 - Some(args) => { 764 - let type_ = args 763 + Some(arguments) => { 764 + let type_ = arguments 765 765 .first() 766 766 .expect("Failed to get type argument of List") 767 767 .clone(); ··· 855 855 module, 856 856 name_location, 857 857 name, 858 - arguments: mut pattern_args, 858 + arguments: mut pattern_arguments, 859 859 spread, 860 860 .. 861 861 } => { ··· 881 881 location, 882 882 name_location, 883 883 name, 884 - arguments: self.infer_pattern_call_args(pattern_args, &[]), 884 + arguments: self.infer_pattern_call_arguments(pattern_arguments, &[]), 885 885 module, 886 886 constructor: Inferred::Unknown, 887 887 spread, ··· 897 897 if let Some(spread_location) = spread { 898 898 // Using the spread operator when you have already provided variables for all of the 899 899 // record's fields throws an error 900 - if pattern_args.len() == field_map.arity as usize { 900 + if pattern_arguments.len() == field_map.arity as usize { 901 901 { 902 902 self.problems.error(Error::UnnecessarySpreadOperator { 903 903 location: spread_location, ··· 913 913 // we have calculate that index and then insert() the discards. It would be faster 914 914 // if we could put the discards anywhere which would let us use push(). 915 915 // Potential future optimisation. 916 - let index_of_first_labelled_arg = pattern_args 916 + let index_of_first_labelled_arg = pattern_arguments 917 917 .iter() 918 918 .position(|argument| argument.label.is_some()) 919 - .unwrap_or(pattern_args.len()); 919 + .unwrap_or(pattern_arguments.len()); 920 920 921 921 // In Gleam we can pass in positional unlabelled args to a constructor 922 922 // even if the field was defined as labelled ··· 940 940 // │ ╰ We supplied 1 labelled arg 941 941 // ╰ We supplied 2 unlabelled args 942 942 // 943 - let supplied_unlabelled_args = index_of_first_labelled_arg; 944 - let supplied_labelled_args = pattern_args 943 + let supplied_unlabelled_arguments = index_of_first_labelled_arg; 944 + let supplied_labelled_arguments = pattern_arguments 945 945 .iter() 946 946 .filter_map(|argument| argument.label.clone()) 947 947 .collect::<HashSet<_>>(); 948 - let constructor_unlabelled_args = 948 + let constructor_unlabelled_arguments = 949 949 field_map.arity - field_map.fields.len() as u32; 950 950 let labelled_arguments_supplied_as_unlabelled = 951 - supplied_unlabelled_args 952 - .saturating_sub(constructor_unlabelled_args as usize); 951 + supplied_unlabelled_arguments 952 + .saturating_sub(constructor_unlabelled_arguments as usize); 953 953 954 954 let mut missing_labels = field_map 955 955 .fields ··· 962 962 .skip(labelled_arguments_supplied_as_unlabelled) 963 963 // ... lastly we still need to remove all those labels that 964 964 // were explicitly supplied in the pattern. 965 - .filter(|label| !supplied_labelled_args.contains(label)); 965 + .filter(|label| !supplied_labelled_arguments.contains(label)); 966 966 967 - while pattern_args.len() < field_map.arity as usize { 967 + while pattern_arguments.len() < field_map.arity as usize { 968 968 let new_call_arg = CallArg { 969 969 value: Pattern::Discard { 970 970 name: "_".into(), ··· 976 976 implicit: Some(ImplicitCallArgOrigin::PatternFieldSpread), 977 977 }; 978 978 979 - pattern_args.insert(index_of_first_labelled_arg, new_call_arg); 979 + pattern_arguments.insert(index_of_first_labelled_arg, new_call_arg); 980 980 } 981 981 } 982 982 983 983 if let Err(error) = field_map.reorder( 984 - &mut pattern_args, 984 + &mut pattern_arguments, 985 985 location, 986 986 IncorrectArityContext::Pattern, 987 987 ) { ··· 993 993 994 994 None => { 995 995 // The fun has no field map and so we error if arguments have been labelled 996 - match assert_no_labelled_arguments(&pattern_args) { 996 + match assert_no_labelled_arguments(&pattern_arguments) { 997 997 Ok(()) => {} 998 998 Err(error) => { 999 999 self.problems.error(error); ··· 1005 1005 if let ValueConstructorVariant::Record { arity, .. } = 1006 1006 &constructor.variant 1007 1007 { 1008 - while pattern_args.len() < usize::from(*arity) { 1009 - pattern_args.push(CallArg { 1008 + while pattern_arguments.len() < usize::from(*arity) { 1009 + pattern_arguments.push(CallArg { 1010 1010 value: Pattern::Discard { 1011 1011 name: "_".into(), 1012 1012 location: spread_location, ··· 1087 1087 self.environment 1088 1088 .instantiate(constructor_type, &mut hashmap![], self.hydrator); 1089 1089 match instantiated_constructor_type.deref() { 1090 - Type::Fn { args, return_ } => { 1090 + Type::Fn { arguments, return_ } => { 1091 1091 self.unify_types(type_.clone(), return_.clone(), location); 1092 1092 1093 1093 if let Some((variable_to_infer, inferred_variant)) = ··· 1099 1099 // We're emitting the incorrect arity error only if we haven't emitted 1100 1100 // one already. This might happen when we can't reorder the field map 1101 1101 // of a constructor because there's not enough labels. 1102 - if args.len() != pattern_args.len() && !incorrect_arity_error { 1102 + if arguments.len() != pattern_arguments.len() && !incorrect_arity_error { 1103 1103 self.error(Error::IncorrectArity { 1104 1104 labels: vec![], 1105 1105 location, 1106 1106 context: IncorrectArityContext::Pattern, 1107 - expected: args.len(), 1108 - given: pattern_args.len(), 1107 + expected: arguments.len(), 1108 + given: pattern_arguments.len(), 1109 1109 }); 1110 1110 } 1111 1111 1112 - let pattern_args = self.infer_pattern_call_args(pattern_args, args); 1112 + let pattern_arguments = 1113 + self.infer_pattern_call_arguments(pattern_arguments, arguments); 1113 1114 1114 1115 Pattern::Constructor { 1115 1116 location, ··· 1117 1118 name, 1118 1119 module, 1119 1120 constructor: Inferred::Known(pattern_constructor), 1120 - arguments: pattern_args, 1121 + arguments: pattern_arguments, 1121 1122 spread, 1122 1123 type_: return_.clone(), 1123 1124 } ··· 1134 1135 self.set_subject_variable_variant(variable_to_infer, inferred_variant); 1135 1136 } 1136 1137 1137 - if !pattern_args.is_empty() { 1138 + if !pattern_arguments.is_empty() { 1138 1139 self.error(Error::IncorrectArity { 1139 1140 labels: vec![], 1140 1141 location, 1141 1142 context: IncorrectArityContext::Pattern, 1142 1143 expected: 0, 1143 - given: pattern_args.len(), 1144 + given: pattern_arguments.len(), 1144 1145 }); 1145 1146 } 1146 1147 Pattern::Constructor { ··· 1161 1162 } 1162 1163 } 1163 1164 1164 - fn infer_pattern_call_args( 1165 + fn infer_pattern_call_arguments( 1165 1166 &mut self, 1166 - pattern_args: Vec<CallArg<UntypedPattern>>, 1167 + pattern_arguments: Vec<CallArg<UntypedPattern>>, 1167 1168 expected_types: &[Arc<Type>], 1168 1169 ) -> Vec<CallArg<TypedPattern>> { 1169 - pattern_args 1170 + pattern_arguments 1170 1171 .into_iter() 1171 1172 .enumerate() 1172 1173 .map(|(index, arg)| {
+17 -15
compiler-core/src/type_/pipe.rs
··· 101 101 102 102 let (kind, call) = match call { 103 103 func @ UntypedExpr::Fn { location, kind, .. } => { 104 - let (func, args, return_type) = self.expr_typer.do_infer_call( 104 + let (func, arguments, return_type) = self.expr_typer.do_infer_call( 105 105 func, 106 106 vec![self.untyped_left_hand_value_variable_call_argument()], 107 107 location, ··· 124 124 kind, 125 125 TypedExpr::Call { 126 126 location, 127 - args, 127 + arguments, 128 128 type_: return_type, 129 129 fun: Box::new(func), 130 130 }, ··· 155 155 156 156 match fun.type_().fn_types() { 157 157 // Rewrite as right(..args)(left) 158 - Some((args, _)) if args.len() == arguments.len() => { 158 + Some((fn_arguments, _)) if fn_arguments.len() == arguments.len() => { 159 159 // We are calling the return value of another function. 160 160 // Without lifting purity tracking into the type system, 161 161 // we have no idea whether it's pure or not! ··· 284 284 fn infer_apply_to_call_pipe( 285 285 &mut self, 286 286 function: TypedExpr, 287 - args: Vec<CallArg<UntypedExpr>>, 287 + arguments: Vec<CallArg<UntypedExpr>>, 288 288 location: SrcSpan, 289 289 ) -> TypedExpr { 290 - let (function, args, type_) = self.expr_typer.do_infer_call_with_known_fun( 290 + let (function, arguments, type_) = self.expr_typer.do_infer_call_with_known_fun( 291 291 function, 292 - args, 292 + arguments, 293 293 location, 294 294 CallKind::Function, 295 295 ); 296 296 let function = TypedExpr::Call { 297 297 location, 298 298 type_, 299 - args, 299 + arguments, 300 300 fun: Box::new(function), 301 301 }; 302 - let args = vec![self.untyped_left_hand_value_variable_call_argument()]; 302 + let arguments = vec![self.untyped_left_hand_value_variable_call_argument()]; 303 303 // TODO: use `.with_unify_error_situation(UnifyErrorSituation::PipeTypeMismatch)` 304 304 // This will require the typing of the arguments to be lifted up out of 305 305 // the function below. If it is not we don't know if the error comes 306 306 // from incorrect usage of the pipe or if it originates from the 307 307 // argument expressions. 308 - let (function, args, type_) = self.expr_typer.do_infer_call_with_known_fun( 308 + let (function, arguments, type_) = self.expr_typer.do_infer_call_with_known_fun( 309 309 function, 310 - args, 310 + arguments, 311 311 location, 312 312 CallKind::Function, 313 313 ); 314 314 TypedExpr::Call { 315 315 location, 316 316 type_, 317 - args, 317 + arguments, 318 318 fun: Box::new(function), 319 319 } 320 320 } ··· 332 332 // the function below. If it is not we don't know if the error comes 333 333 // from incorrect usage of the pipe or if it originates from the 334 334 // argument expressions. 335 - let (fun, args, type_) = self.expr_typer.do_infer_call_with_known_fun( 335 + let (fun, arguments, type_) = self.expr_typer.do_infer_call_with_known_fun( 336 336 function, 337 337 arguments, 338 338 location, ··· 341 341 TypedExpr::Call { 342 342 location, 343 343 type_, 344 - args, 344 + arguments, 345 345 fun: Box::new(fun), 346 346 } 347 347 } ··· 391 391 location: function_location, 392 392 type_: return_type, 393 393 fun: function, 394 - args: vec![self.typed_left_hand_value_variable_call_argument()], 394 + arguments: vec![self.typed_left_hand_value_variable_call_argument()], 395 395 } 396 396 } 397 397 ··· 404 404 }; 405 405 406 406 match types { 407 - (Type::Fn { args: a, .. }, Type::Fn { args: b, .. }) if a.len() == b.len() => { 407 + (Type::Fn { arguments: a, .. }, Type::Fn { arguments: b, .. }) 408 + if a.len() == b.len() => 409 + { 408 410 match (a.first(), b.first()) { 409 411 (Some(a), Some(b)) => unify(a.clone(), b.clone()).is_err(), 410 412 _ => false,
+13 -13
compiler-core/src/type_/prelude.rs
··· 68 68 name: INT.into(), 69 69 module: PRELUDE_MODULE_NAME.into(), 70 70 package: PRELUDE_PACKAGE_NAME.into(), 71 - args: vec![], 71 + arguments: vec![], 72 72 inferred_variant: None, 73 73 }) 74 74 } 75 75 76 76 pub fn float() -> Arc<Type> { 77 77 Arc::new(Type::Named { 78 - args: vec![], 78 + arguments: vec![], 79 79 publicity: Publicity::Public, 80 80 name: FLOAT.into(), 81 81 module: PRELUDE_MODULE_NAME.into(), ··· 96 96 }; 97 97 98 98 Arc::new(Type::Named { 99 - args: vec![], 99 + arguments: vec![], 100 100 publicity: Publicity::Public, 101 101 name: BOOL.into(), 102 102 module: PRELUDE_MODULE_NAME.into(), ··· 107 107 108 108 pub fn string() -> Arc<Type> { 109 109 Arc::new(Type::Named { 110 - args: vec![], 110 + arguments: vec![], 111 111 publicity: Publicity::Public, 112 112 name: STRING.into(), 113 113 module: PRELUDE_MODULE_NAME.into(), ··· 118 118 119 119 pub fn nil() -> Arc<Type> { 120 120 Arc::new(Type::Named { 121 - args: vec![], 121 + arguments: vec![], 122 122 publicity: Publicity::Public, 123 123 name: NIL.into(), 124 124 module: PRELUDE_MODULE_NAME.into(), ··· 133 133 name: LIST.into(), 134 134 module: PRELUDE_MODULE_NAME.into(), 135 135 package: PRELUDE_PACKAGE_NAME.into(), 136 - args: vec![t], 136 + arguments: vec![t], 137 137 inferred_variant: None, 138 138 }) 139 139 } ··· 148 148 name: RESULT.into(), 149 149 module: PRELUDE_MODULE_NAME.into(), 150 150 package: PRELUDE_PACKAGE_NAME.into(), 151 - args: vec![a, e], 151 + arguments: vec![a, e], 152 152 inferred_variant: variant_index, 153 153 }) 154 154 } ··· 157 157 Arc::new(Type::Tuple { elements }) 158 158 } 159 159 160 - pub fn fn_(args: Vec<Arc<Type>>, return_: Arc<Type>) -> Arc<Type> { 161 - Arc::new(Type::Fn { return_, args }) 160 + pub fn fn_(arguments: Vec<Arc<Type>>, return_: Arc<Type>) -> Arc<Type> { 161 + Arc::new(Type::Fn { return_, arguments }) 162 162 } 163 163 164 164 pub fn named( ··· 166 166 module: &str, 167 167 name: &str, 168 168 publicity: Publicity, 169 - args: Vec<Arc<Type>>, 169 + arguments: Vec<Arc<Type>>, 170 170 ) -> Arc<Type> { 171 171 Arc::new(Type::Named { 172 172 publicity, 173 173 package: package.into(), 174 174 module: module.into(), 175 175 name: name.into(), 176 - args, 176 + arguments, 177 177 inferred_variant: None, 178 178 }) 179 179 } 180 180 181 181 pub fn bit_array() -> Arc<Type> { 182 182 Arc::new(Type::Named { 183 - args: vec![], 183 + arguments: vec![], 184 184 publicity: Publicity::Public, 185 185 name: BIT_ARRAY.into(), 186 186 module: PRELUDE_MODULE_NAME.into(), ··· 191 191 192 192 pub fn utf_codepoint() -> Arc<Type> { 193 193 Arc::new(Type::Named { 194 - args: vec![], 194 + arguments: vec![], 195 195 publicity: Publicity::Public, 196 196 name: UTF_CODEPOINT.into(), 197 197 module: PRELUDE_MODULE_NAME.into(),
+25 -20
compiler-core/src/type_/pretty.rs
··· 53 53 pub fn print<'a>(&mut self, type_: &Type) -> Document<'a> { 54 54 match type_ { 55 55 Type::Named { 56 - name, args, module, .. 56 + name, 57 + arguments, 58 + module, 59 + .. 57 60 } => { 58 61 let doc = if self.name_clashes_if_unqualified(name, module) { 59 62 qualify_type_name(module, name) ··· 61 64 let _ = self.printed_types.insert(name.clone(), module.clone()); 62 65 name.to_doc() 63 66 }; 64 - if args.is_empty() { 67 + if arguments.is_empty() { 65 68 doc 66 69 } else { 67 70 doc.append("(") 68 - .append(self.args_to_gleam_doc(args)) 71 + .append(self.arguments_to_gleam_doc(arguments)) 69 72 .append(")") 70 73 } 71 74 } 72 75 73 - Type::Fn { args, return_ } => "fn(" 76 + Type::Fn { arguments, return_ } => "fn(" 74 77 .to_doc() 75 - .append(self.args_to_gleam_doc(args)) 78 + .append(self.arguments_to_gleam_doc(arguments)) 76 79 .append(") ->") 77 80 .append( 78 81 break_("", " ") ··· 83 86 84 87 Type::Var { type_, .. } => self.type_var_doc(&type_.borrow()), 85 88 86 - Type::Tuple { elements, .. } => self.args_to_gleam_doc(elements).surround("#(", ")"), 89 + Type::Tuple { elements, .. } => { 90 + self.arguments_to_gleam_doc(elements).surround("#(", ")") 91 + } 87 92 } 88 93 } 89 94 ··· 139 144 chars.into_iter().rev().collect() 140 145 } 141 146 142 - fn args_to_gleam_doc(&mut self, args: &[Arc<Type>]) -> Document<'static> { 143 - if args.is_empty() { 147 + fn arguments_to_gleam_doc(&mut self, arguments: &[Arc<Type>]) -> Document<'static> { 148 + if arguments.is_empty() { 144 149 return nil(); 145 150 } 146 151 147 - let args = join( 148 - args.iter().map(|type_| self.print(type_).group()), 152 + let arguments = join( 153 + arguments.iter().map(|type_| self.print(type_).group()), 149 154 break_(",", ", "), 150 155 ); 151 156 break_("", "") 152 - .append(args) 157 + .append(arguments) 153 158 .nest(INDENT) 154 159 .append(break_(",", "")) 155 160 .group() ··· 258 263 package: "whatever".into(), 259 264 name: "Int".into(), 260 265 publicity: Publicity::Public, 261 - args: vec![], 266 + arguments: vec![], 262 267 inferred_variant: None, 263 268 }, 264 269 "Int", ··· 269 274 package: "whatever".into(), 270 275 name: "Pair".into(), 271 276 publicity: Publicity::Public, 272 - args: vec![ 277 + arguments: vec![ 273 278 Arc::new(Type::Named { 274 279 module: "whatever".into(), 275 280 package: "whatever".into(), 276 281 name: "Int".into(), 277 282 publicity: Publicity::Public, 278 - args: vec![], 283 + arguments: vec![], 279 284 inferred_variant: None, 280 285 }), 281 286 Arc::new(Type::Named { ··· 283 288 package: "whatever".into(), 284 289 name: "Bool".into(), 285 290 publicity: Publicity::Public, 286 - args: vec![], 291 + arguments: vec![], 287 292 inferred_variant: None, 288 293 }), 289 294 ], ··· 293 298 ); 294 299 assert_string!( 295 300 Type::Fn { 296 - args: vec![ 301 + arguments: vec![ 297 302 Arc::new(Type::Named { 298 - args: vec![], 303 + arguments: vec![], 299 304 module: "whatever".into(), 300 305 package: "whatever".into(), 301 306 name: "Int".into(), ··· 303 308 inferred_variant: None, 304 309 }), 305 310 Arc::new(Type::Named { 306 - args: vec![], 311 + arguments: vec![], 307 312 module: "whatever".into(), 308 313 package: "whatever".into(), 309 314 name: "Bool".into(), ··· 312 317 }), 313 318 ], 314 319 return_: Arc::new(Type::Named { 315 - args: vec![], 320 + arguments: vec![], 316 321 module: "whatever".into(), 317 322 package: "whatever".into(), 318 323 name: "Bool".into(), ··· 326 331 Type::Var { 327 332 type_: Arc::new(RefCell::new(TypeVar::Link { 328 333 type_: Arc::new(Type::Named { 329 - args: vec![], 334 + arguments: vec![], 330 335 module: "whatever".into(), 331 336 package: "whatever".into(), 332 337 name: "Int".into(),
+34 -28
compiler-core/src/type_/printer.rs
··· 163 163 ) { 164 164 match type_ { 165 165 Type::Named { 166 - module, name, args, .. 167 - } if compare_arguments(args, parameters) => { 166 + module, 167 + name, 168 + arguments, 169 + .. 170 + } if compare_arguments(arguments, parameters) => { 168 171 self.named_type_in_scope(module.clone(), name.clone(), local_alias); 169 172 } 170 173 Type::Named { .. } | Type::Fn { .. } | Type::Var { .. } | Type::Tuple { .. } => { ··· 352 355 fn print(&mut self, type_: &Type, buffer: &mut EcoString, print_mode: PrintMode) { 353 356 match type_ { 354 357 Type::Named { 355 - name, args, module, .. 358 + name, 359 + arguments, 360 + module, 361 + .. 356 362 } => { 357 363 let (module, name) = match self.names.named_type(module, name, print_mode) { 358 364 NameContextInformation::Qualified(m, n) => (Some(m), n), ··· 370 376 } 371 377 buffer.push_str(name); 372 378 373 - if !args.is_empty() { 379 + if !arguments.is_empty() { 374 380 buffer.push('('); 375 - self.print_arguments(args, buffer, print_mode); 381 + self.print_arguments(arguments, buffer, print_mode); 376 382 buffer.push(')'); 377 383 } 378 384 } 379 385 380 - Type::Fn { args, return_ } => { 386 + Type::Fn { arguments, return_ } => { 381 387 buffer.push_str("fn("); 382 - self.print_arguments(args, buffer, print_mode); 388 + self.print_arguments(arguments, buffer, print_mode); 383 389 buffer.push_str(") -> "); 384 390 self.print(return_, buffer, print_mode); 385 391 } ··· 416 422 417 423 fn print_arguments( 418 424 &mut self, 419 - args: &[Arc<Type>], 425 + arguments: &[Arc<Type>], 420 426 type_str: &mut EcoString, 421 427 print_mode: PrintMode, 422 428 ) { 423 - for (i, arg) in args.iter().enumerate() { 424 - self.print(arg, type_str, print_mode); 425 - if i < args.len() - 1 { 429 + for (i, argument) in arguments.iter().enumerate() { 430 + self.print(argument, type_str, print_mode); 431 + if i < arguments.len() - 1 { 426 432 type_str.push_str(", "); 427 433 } 428 434 } ··· 479 485 480 486 let type_ = Type::Named { 481 487 name: "Tiger".into(), 482 - args: vec![], 488 + arguments: vec![], 483 489 module: "mod".into(), 484 490 publicity: crate::ast::Publicity::Public, 485 491 package: "".into(), ··· 497 503 498 504 let type_ = Type::Named { 499 505 name: "Int".into(), 500 - args: vec![], 506 + arguments: vec![], 501 507 module: "gleam".into(), 502 508 publicity: crate::ast::Publicity::Public, 503 509 package: "".into(), ··· 518 524 519 525 let type_ = Type::Named { 520 526 name: "Int".into(), 521 - args: vec![], 527 + arguments: vec![], 522 528 module: "gleam".into(), 523 529 publicity: crate::ast::Publicity::Public, 524 530 package: "".into(), ··· 567 573 elements: vec![ 568 574 Arc::new(Type::Named { 569 575 name: "Int".into(), 570 - args: vec![], 576 + arguments: vec![], 571 577 module: "gleam".into(), 572 578 publicity: crate::ast::Publicity::Public, 573 579 package: "".into(), ··· 575 581 }), 576 582 Arc::new(Type::Named { 577 583 name: "String".into(), 578 - args: vec![], 584 + arguments: vec![], 579 585 module: "gleam".into(), 580 586 publicity: crate::ast::Publicity::Public, 581 587 package: "".into(), ··· 595 601 let mut printer = Printer::new(&names); 596 602 597 603 let type_ = Type::Fn { 598 - args: vec![ 604 + arguments: vec![ 599 605 Arc::new(Type::Named { 600 606 name: "Int".into(), 601 - args: vec![], 607 + arguments: vec![], 602 608 module: "gleam".into(), 603 609 publicity: crate::ast::Publicity::Public, 604 610 package: "".into(), ··· 606 612 }), 607 613 Arc::new(Type::Named { 608 614 name: "String".into(), 609 - args: vec![], 615 + arguments: vec![], 610 616 module: "gleam".into(), 611 617 publicity: crate::ast::Publicity::Public, 612 618 package: "".into(), ··· 615 621 ], 616 622 return_: Arc::new(Type::Named { 617 623 name: "Bool".into(), 618 - args: vec![], 624 + arguments: vec![], 619 625 module: "gleam".into(), 620 626 publicity: crate::ast::Publicity::Public, 621 627 package: "".into(), ··· 640 646 641 647 let type_ = Type::Named { 642 648 name: "Cat".into(), 643 - args: vec![], 649 + arguments: vec![], 644 650 module: "mod1".into(), 645 651 publicity: crate::ast::Publicity::Public, 646 652 package: "".into(), ··· 662 668 663 669 let type_ = Type::Named { 664 670 name: "Tiger".into(), 665 - args: vec![Arc::new(Type::Var { 671 + arguments: vec![Arc::new(Type::Var { 666 672 type_: Arc::new(std::cell::RefCell::new(TypeVar::Generic { id: 0 })), 667 673 })], 668 674 module: "mod".into(), ··· 686 692 687 693 let type_ = Type::Named { 688 694 name: "Cat".into(), 689 - args: vec![Arc::new(Type::Var { 695 + arguments: vec![Arc::new(Type::Var { 690 696 type_: Arc::new(std::cell::RefCell::new(TypeVar::Generic { id: 0 })), 691 697 })], 692 698 module: "mod".into(), ··· 704 710 let mut printer = Printer::new(&names); 705 711 let type_ = Type::Named { 706 712 name: "Cat".into(), 707 - args: vec![], 713 + arguments: vec![], 708 714 module: "one/two/three".into(), 709 715 publicity: crate::ast::Publicity::Public, 710 716 package: "".into(), ··· 732 738 733 739 let type_ = Type::Named { 734 740 name: "Cat".into(), 735 - args: vec![], 741 + arguments: vec![], 736 742 module: "mod1".into(), 737 743 publicity: crate::ast::Publicity::Public, 738 744 package: "".into(), ··· 760 766 761 767 let type_ = Type::Named { 762 768 name: "Cat".into(), 763 - args: vec![], 769 + arguments: vec![], 764 770 module: "mod".into(), 765 771 publicity: crate::ast::Publicity::Public, 766 772 package: "".into(), ··· 769 775 770 776 let typ1 = Type::Named { 771 777 name: "Cat".into(), 772 - args: vec![], 778 + arguments: vec![], 773 779 module: "mod2".into(), 774 780 publicity: crate::ast::Publicity::Public, 775 781 package: "".into(), ··· 791 797 792 798 let type_ = Type::Named { 793 799 name: "Tiger".into(), 794 - args: vec![ 800 + arguments: vec![ 795 801 Arc::new(Type::Var { 796 802 type_: Arc::new(std::cell::RefCell::new(TypeVar::Generic { id: 0 })), 797 803 }),
+11 -11
compiler-core/src/type_/tests.rs
··· 606 606 struct Case { 607 607 arity: u32, 608 608 fields: HashMap<EcoString, u32>, 609 - args: Vec<CallArg<UntypedExpr>>, 609 + arguments: Vec<CallArg<UntypedExpr>>, 610 610 expected_result: Result<(), crate::type_::Error>, 611 - expected_args: Vec<CallArg<UntypedExpr>>, 611 + expected_arguments: Vec<CallArg<UntypedExpr>>, 612 612 } 613 613 614 614 impl Case { 615 615 fn test(self) { 616 - let mut args = self.args; 616 + let mut arguments = self.arguments; 617 617 let fm = FieldMap { 618 618 arity: self.arity, 619 619 fields: self.fields, ··· 621 621 let location = SrcSpan { start: 0, end: 0 }; 622 622 assert_eq!( 623 623 self.expected_result, 624 - fm.reorder(&mut args, location, IncorrectArityContext::Function) 624 + fm.reorder(&mut arguments, location, IncorrectArityContext::Function) 625 625 ); 626 - assert_eq!(self.expected_args, args); 626 + assert_eq!(self.expected_arguments, arguments); 627 627 } 628 628 } 629 629 630 630 Case { 631 631 arity: 0, 632 632 fields: HashMap::new(), 633 - args: vec![], 633 + arguments: vec![], 634 634 expected_result: Ok(()), 635 - expected_args: vec![], 635 + expected_arguments: vec![], 636 636 } 637 637 .test(); 638 638 639 639 Case { 640 640 arity: 3, 641 641 fields: HashMap::new(), 642 - args: vec![ 642 + arguments: vec![ 643 643 CallArg { 644 644 implicit: None, 645 645 location: Default::default(), ··· 660 660 }, 661 661 ], 662 662 expected_result: Ok(()), 663 - expected_args: vec![ 663 + expected_arguments: vec![ 664 664 CallArg { 665 665 implicit: None, 666 666 location: Default::default(), ··· 686 686 Case { 687 687 arity: 3, 688 688 fields: [("last".into(), 2)].into(), 689 - args: vec![ 689 + arguments: vec![ 690 690 CallArg { 691 691 implicit: None, 692 692 location: Default::default(), ··· 707 707 }, 708 708 ], 709 709 expected_result: Ok(()), 710 - expected_args: vec![ 710 + expected_arguments: vec![ 711 711 CallArg { 712 712 implicit: None, 713 713 location: Default::default(),
+1 -1
compiler-core/src/type_/tests/pretty.rs
··· 18 18 package: "wibble".into(), 19 19 module: "one/two".into(), 20 20 name: "Bool".into(), 21 - args: vec![], 21 + arguments: vec![], 22 22 inferred_variant: None, 23 23 }) 24 24 }
+5 -5
compiler-core/src/warning.rs
··· 999 999 type_::Warning::TodoOrPanicUsedAsFunction { 1000 1000 kind, 1001 1001 location, 1002 - args_location, 1003 - args, 1002 + arguments_location, 1003 + arguments, 1004 1004 } => { 1005 1005 let title = match kind { 1006 1006 TodoOrPanic::Todo => "Todo used as a function".into(), 1007 1007 TodoOrPanic::Panic => "Panic used as a function".into(), 1008 1008 }; 1009 - let label_location = match args_location { 1009 + let label_location = match arguments_location { 1010 1010 None => location, 1011 1011 Some(location) => location, 1012 1012 }; ··· 1015 1015 TodoOrPanic::Panic => "panic", 1016 1016 }; 1017 1017 let mut text = format!("`{name}` is not a function"); 1018 - match args { 1018 + match arguments { 1019 1019 0 => text.push_str(&format!( 1020 1020 ", you can just write `{name}` instead of `{name}()`." 1021 1021 )), ··· 1027 1027 ), 1028 1028 }; 1029 1029 1030 - match args { 1030 + match arguments { 1031 1031 0 => {} 1032 1032 _ => text.push_str(&format!( 1033 1033 "\n\nHint: if you want to display an error message you should write