From ae8f82ccb038b70adeaf250898f7051110ef1f52 Mon Sep 17 00:00:00 2001 From: ychenfo Date: Thu, 13 Jan 2022 03:21:26 +0800 Subject: [PATCH] nac3core: fix broken tests --- nac3core/src/codegen/test.rs | 4 ++-- nac3core/src/toplevel/test.rs | 10 +++++++--- nac3core/src/typecheck/type_inferencer/test.rs | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/nac3core/src/codegen/test.rs b/nac3core/src/codegen/test.rs index 4e63fd300..b3963d877 100644 --- a/nac3core/src/codegen/test.rs +++ b/nac3core/src/codegen/test.rs @@ -46,8 +46,8 @@ impl SymbolResolver for Resolver { _: &[Arc>], _: &PrimitiveStore, str: StrRef, - ) -> Option { - self.id_to_type.get(&str).cloned() + ) -> Result { + self.id_to_type.get(&str).cloned().ok_or_else(|| format!("cannot find symbol `{}`", str)) } fn get_symbol_value<'ctx, 'a>( diff --git a/nac3core/src/toplevel/test.rs b/nac3core/src/toplevel/test.rs index 1aef5771b..0fb36ab1b 100644 --- a/nac3core/src/toplevel/test.rs +++ b/nac3core/src/toplevel/test.rs @@ -45,9 +45,13 @@ impl SymbolResolver for Resolver { _: &[Arc>], _: &PrimitiveStore, str: StrRef, - ) -> Option { - let ret = self.0.id_to_type.lock().get(&str).cloned(); - ret + ) -> Result { + self.0 + .id_to_type + .lock() + .get(&str) + .cloned() + .ok_or_else(|| format!("cannot find symbol `{}`", str)) } fn get_symbol_value<'ctx, 'a>( diff --git a/nac3core/src/typecheck/type_inferencer/test.rs b/nac3core/src/typecheck/type_inferencer/test.rs index 0d1492ca5..b46330642 100644 --- a/nac3core/src/typecheck/type_inferencer/test.rs +++ b/nac3core/src/typecheck/type_inferencer/test.rs @@ -29,8 +29,8 @@ impl SymbolResolver for Resolver { _: &[Arc>], _: &PrimitiveStore, str: StrRef, - ) -> Option { - self.id_to_type.get(&str).cloned() + ) -> Result { + self.id_to_type.get(&str).cloned().ok_or_else(|| format!("cannot find symbol `{}`", str)) } fn get_symbol_value<'ctx, 'a>(