spelling (#264)
Co-authored-by: wylited <ds@m-labs.hk> Co-committed-by: wylited <ds@m-labs.hk>
This commit is contained in:
parent
6972689469
commit
e94b25f544
@ -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>(
|
||||
|
@ -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<u32> = HashSet::new();
|
||||
let mut occurred_type_var_id: HashSet<u32> = 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<u32, Type> = 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<FuncArg> = {
|
||||
// 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
|
||||
|
@ -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<Arc<dyn SymbolResolver + Send + Sync>>,
|
||||
|
@ -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
|
||||
|
@ -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)]
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user