From e94b25f5443edfb1567d635b32571150af1e4560 Mon Sep 17 00:00:00 2001 From: wylited Date: Wed, 13 Apr 2022 11:32:31 +0800 Subject: [PATCH] spelling (#264) Co-authored-by: wylited Co-committed-by: wylited --- nac3core/src/codegen/generator.rs | 2 +- nac3core/src/toplevel/composer.rs | 20 ++++++++++---------- nac3core/src/toplevel/helper.rs | 2 +- nac3core/src/toplevel/type_annotation.rs | 2 +- nac3core/src/typecheck/typedef/mod.rs | 2 +- nac3core/src/typecheck/typedef/test.rs | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/nac3core/src/codegen/generator.rs b/nac3core/src/codegen/generator.rs index 4fcbfdb01..22d0eac2b 100644 --- a/nac3core/src/codegen/generator.rs +++ b/nac3core/src/codegen/generator.rs @@ -36,7 +36,7 @@ pub trait CodeGenerator { } /// Generate object constructor and returns the constructed object. - /// - signature: Function signature of the contructor. + /// - signature: Function signature of the constructor. /// - def: Class definition for the constructor class. /// - params: Function parameters. fn gen_constructor<'ctx, 'a>( diff --git a/nac3core/src/toplevel/composer.rs b/nac3core/src/toplevel/composer.rs index 856801136..c002588c1 100644 --- a/nac3core/src/toplevel/composer.rs +++ b/nac3core/src/toplevel/composer.rs @@ -434,11 +434,11 @@ impl TopLevelComposer { // check if all are unique type vars let all_unique_type_var = { - let mut occured_type_var_id: HashSet = HashSet::new(); + let mut occurred_type_var_id: HashSet = HashSet::new(); type_vars.iter().all(|x| { let ty = unifier.get_ty(*x); if let TypeEnum::TVar { id, .. } = ty.as_ref() { - occured_type_var_id.insert(*id) + occurred_type_var_id.insert(*id) } else { false } @@ -536,7 +536,7 @@ impl TopLevelComposer { } has_base = true; - // the function parse_ast_to make sure that no type var occured in + // the function parse_ast_to make sure that no type var occurred in // bast_ty if it is a CustomClassKind let base_ty = parse_ast_to_type_annotation_kinds( class_resolver, @@ -696,7 +696,7 @@ impl TopLevelComposer { return Err(errors.into_iter().sorted().join("\n----------\n")); } - // handle the inheritanced methods and fields + // handle the inherited methods and fields // Note: we cannot defer error handling til the end of the loop, because there is loop // carried dependency, ignoring the error (temporarily) will cause all assumptions to break // and produce weird error messages @@ -825,9 +825,9 @@ impl TopLevelComposer { let mut function_var_map: HashMap = HashMap::new(); let arg_types = { // make sure no duplicate parameter - let mut defined_paramter_name: HashSet<_> = HashSet::new(); + let mut defined_parameter_name: HashSet<_> = HashSet::new(); for x in args.args.iter() { - if !defined_paramter_name.insert(x.node.arg) + if !defined_parameter_name.insert(x.node.arg) || keyword_list.contains(&x.node.arg) { return Err(format!( @@ -1074,10 +1074,10 @@ impl TopLevelComposer { let arg_types: Vec = { // check method parameters cannot have same name - let mut defined_paramter_name: HashSet<_> = HashSet::new(); + let mut defined_parameter_name: HashSet<_> = HashSet::new(); let zelf: StrRef = "self".into(); for x in args.args.iter() { - if !defined_paramter_name.insert(x.node.arg) + if !defined_parameter_name.insert(x.node.arg) || (keyword_list.contains(&x.node.arg) && x.node.arg != zelf) { return Err(format!( @@ -1227,7 +1227,7 @@ impl TopLevelComposer { dummy_return_type } else { // if do not have return annotation, return none - // for uniform handling, still use type annoatation + // for uniform handling, still use type annotation let dummy_return_type = unifier.get_dummy_var().0; type_var_to_concrete_def.insert( dummy_return_type, @@ -1468,7 +1468,7 @@ impl TopLevelComposer { Ok(()) } - /// step 5, analyze and call type inferecer to fill the `instance_to_stmt` of topleveldef::function + /// step 5, analyze and call type inferencer to fill the `instance_to_stmt` of topleveldef::function fn analyze_function_instance(&mut self) -> Result<(), String> { // first get the class contructor type correct for the following type check in function body // also do class field instantiation check diff --git a/nac3core/src/toplevel/helper.rs b/nac3core/src/toplevel/helper.rs index 687e70bf2..c6311862d 100644 --- a/nac3core/src/toplevel/helper.rs +++ b/nac3core/src/toplevel/helper.rs @@ -149,7 +149,7 @@ impl TopLevelComposer { } /// already include the definition_id of itself inside the ancestors vector - /// when first regitering, the type_vars, fields, methods, ancestors are invalid + /// when first registering, the type_vars, fields, methods, ancestors are invalid pub fn make_top_level_class_def( index: usize, resolver: Option>, diff --git a/nac3core/src/toplevel/type_annotation.rs b/nac3core/src/toplevel/type_annotation.rs index bccd78675..116a6b4cd 100644 --- a/nac3core/src/toplevel/type_annotation.rs +++ b/nac3core/src/toplevel/type_annotation.rs @@ -436,7 +436,7 @@ pub fn get_type_from_type_annotation_kinds( /// the type of `self` should be similar to `A[T, V]`, where `T`, `V` /// considered to be type variables associated with the class \ /// \ -/// But note that here we do not make a duplication of `T`, `V`, we direclty +/// But note that here we do not make a duplication of `T`, `V`, we directly /// use them as they are in the TopLevelDef::Class since those in the /// TopLevelDef::Class.type_vars will be substitute later when seeing applications/instantiations /// the Type of their fields and methods will also be subst when application/instantiation diff --git a/nac3core/src/typecheck/typedef/mod.rs b/nac3core/src/typecheck/typedef/mod.rs index 16248f812..f2e7b57bc 100644 --- a/nac3core/src/typecheck/typedef/mod.rs +++ b/nac3core/src/typecheck/typedef/mod.rs @@ -16,7 +16,7 @@ use crate::toplevel::{DefinitionId, TopLevelContext, TopLevelDef}; #[cfg(test)] mod test; -/// Handle for a type, implementated as a key in the unification table. +/// Handle for a type, implemented as a key in the unification table. pub type Type = UnificationKey; #[derive(Clone, Copy, PartialEq, Eq, Debug)] diff --git a/nac3core/src/typecheck/typedef/test.rs b/nac3core/src/typecheck/typedef/test.rs index 2e56a347d..30c183bd8 100644 --- a/nac3core/src/typecheck/typedef/test.rs +++ b/nac3core/src/typecheck/typedef/test.rs @@ -309,7 +309,7 @@ fn test_unify( fn test_invalid_unification( variable_count: u32, unify_pairs: &[(&'static str, &'static str)], - errornous_pair: ((&'static str, &'static str), &'static str), + erroneous_pair: ((&'static str, &'static str), &'static str), ) { let mut env = TestEnvironment::new(); let mut mapping = HashMap::new(); @@ -326,11 +326,11 @@ fn test_invalid_unification( pairs.push((t1, t2)); } let (t1, t2) = - (env.parse(errornous_pair.0 .0, &mapping), env.parse(errornous_pair.0 .1, &mapping)); + (env.parse(erroneous_pair.0 .0, &mapping), env.parse(erroneous_pair.0 .1, &mapping)); for (a, b) in pairs { env.unifier.unify(a, b).unwrap(); } - assert_eq!(env.unify(t1, t2), Err(errornous_pair.1.to_string())); + assert_eq!(env.unify(t1, t2), Err(erroneous_pair.1.to_string())); } #[test]