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 4e63fd30..b3963d87 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 1aef5771..0fb36ab1 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 0d1492ca..b4633064 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>(