From 06fcbff876159d5f3c37307f44086dbe001053eb 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 the None token is parsed as a special ast::constant instead of an ast::name, and we use None now as a special value of type Option[Any] --- 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 d5df9f2a..1bb27013 100644 --- a/nac3core/src/symbol_resolver.rs +++ b/nac3core/src/symbol_resolver.rs @@ -145,12 +145,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(), @@ -175,14 +174,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 { @@ -197,8 +195,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 fa73eb5c..87fe744e 100644 --- a/nac3core/src/toplevel/composer.rs +++ b/nac3core/src/toplevel/composer.rs @@ -1748,9 +1748,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()); } @@ -1773,9 +1771,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 63cea2f8..2368d6cd 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() {