1
0
forked from M-Labs/nac3

nac3core: fix broken tests

This commit is contained in:
ychenfo 2022-01-13 03:21:26 +08:00
parent 4a1a4dc076
commit ae8f82ccb0
3 changed files with 11 additions and 7 deletions
nac3core/src
codegen
toplevel
typecheck/type_inferencer

View File

@ -46,8 +46,8 @@ impl SymbolResolver for Resolver {
_: &[Arc<RwLock<TopLevelDef>>], _: &[Arc<RwLock<TopLevelDef>>],
_: &PrimitiveStore, _: &PrimitiveStore,
str: StrRef, str: StrRef,
) -> Option<Type> { ) -> Result<Type, String> {
self.id_to_type.get(&str).cloned() self.id_to_type.get(&str).cloned().ok_or_else(|| format!("cannot find symbol `{}`", str))
} }
fn get_symbol_value<'ctx, 'a>( fn get_symbol_value<'ctx, 'a>(

View File

@ -45,9 +45,13 @@ impl SymbolResolver for Resolver {
_: &[Arc<RwLock<TopLevelDef>>], _: &[Arc<RwLock<TopLevelDef>>],
_: &PrimitiveStore, _: &PrimitiveStore,
str: StrRef, str: StrRef,
) -> Option<Type> { ) -> Result<Type, String> {
let ret = self.0.id_to_type.lock().get(&str).cloned(); self.0
ret .id_to_type
.lock()
.get(&str)
.cloned()
.ok_or_else(|| format!("cannot find symbol `{}`", str))
} }
fn get_symbol_value<'ctx, 'a>( fn get_symbol_value<'ctx, 'a>(

View File

@ -29,8 +29,8 @@ impl SymbolResolver for Resolver {
_: &[Arc<RwLock<TopLevelDef>>], _: &[Arc<RwLock<TopLevelDef>>],
_: &PrimitiveStore, _: &PrimitiveStore,
str: StrRef, str: StrRef,
) -> Option<Type> { ) -> Result<Type, String> {
self.id_to_type.get(&str).cloned() self.id_to_type.get(&str).cloned().ok_or_else(|| format!("cannot find symbol `{}`", str))
} }
fn get_symbol_value<'ctx, 'a>( fn get_symbol_value<'ctx, 'a>(