From be6b6c94408c117b769bcab0595581a6a403bd81 Mon Sep 17 00:00:00 2001 From: ychenfo Date: Tue, 15 Mar 2022 02:45:01 +0800 Subject: [PATCH] nac3core: remove previous handling of None not to confuse with option none, and the None token is parsed as a special ast::constant instead of an ast::name so the handling is invalid --- nac3core/src/symbol_resolver.rs | 20 ++++++++------------ nac3core/src/toplevel/composer.rs | 4 ---- nac3core/src/toplevel/type_annotation.rs | 2 -- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/nac3core/src/symbol_resolver.rs b/nac3core/src/symbol_resolver.rs index 96f941d..b8fc9f2 100644 --- a/nac3core/src/symbol_resolver.rs +++ b/nac3core/src/symbol_resolver.rs @@ -153,12 +153,11 @@ pub trait SymbolResolver { } thread_local! { - static IDENTIFIER_ID: [StrRef; 12] = [ + static IDENTIFIER_ID: [StrRef; 11] = [ "int32".into(), "int64".into(), "float".into(), "bool".into(), - "None".into(), "virtual".into(), "list".into(), "tuple".into(), @@ -183,14 +182,13 @@ pub fn parse_type_annotation( let int64_id = ids[1]; let float_id = ids[2]; let bool_id = ids[3]; - let none_id = ids[4]; - let virtual_id = ids[5]; - let list_id = ids[6]; - let tuple_id = ids[7]; - let str_id = ids[8]; - let exn_id = ids[9]; - let uint32_id = ids[10]; - let uint64_id = ids[11]; + let virtual_id = ids[4]; + let list_id = ids[5]; + let tuple_id = ids[6]; + let str_id = ids[7]; + let exn_id = ids[8]; + let uint32_id = ids[9]; + let uint64_id = ids[10]; let name_handling = |id: &StrRef, loc: Location, unifier: &mut Unifier| { if *id == int32_id { @@ -205,8 +203,6 @@ pub fn parse_type_annotation( Ok(primitives.float) } else if *id == bool_id { Ok(primitives.bool) - } else if *id == none_id { - Ok(primitives.none) } else if *id == str_id { Ok(primitives.str) } else if *id == exn_id { diff --git a/nac3core/src/toplevel/composer.rs b/nac3core/src/toplevel/composer.rs index 910bfe0..bfed669 100644 --- a/nac3core/src/toplevel/composer.rs +++ b/nac3core/src/toplevel/composer.rs @@ -1784,9 +1784,7 @@ impl TopLevelComposer { }) }; let mut identifiers = { - // NOTE: none and function args? let mut result: HashSet<_> = HashSet::new(); - result.insert("None".into()); if self_type.is_some() { result.insert("self".into()); } @@ -1809,9 +1807,7 @@ impl TopLevelComposer { }, unifier, variable_mapping: { - // NOTE: none and function args? let mut result: HashMap = HashMap::new(); - result.insert("None".into(), primitives_ty.none); if let Some(self_ty) = self_type { result.insert("self".into(), self_ty); } diff --git a/nac3core/src/toplevel/type_annotation.rs b/nac3core/src/toplevel/type_annotation.rs index 337ec9d..423a418 100644 --- a/nac3core/src/toplevel/type_annotation.rs +++ b/nac3core/src/toplevel/type_annotation.rs @@ -72,8 +72,6 @@ pub fn parse_ast_to_type_annotation_kinds( Ok(TypeAnnotation::Primitive(primitives.float)) } else if id == &"bool".into() { Ok(TypeAnnotation::Primitive(primitives.bool)) - } else if id == &"None".into() { - Ok(TypeAnnotation::Primitive(primitives.none)) } else if id == &"str".into() { Ok(TypeAnnotation::Primitive(primitives.str)) } else if id == &"Exception".into() {