diff --git a/brilirs/src/check.rs b/brilirs/src/check.rs index f14a56e12..09075d705 100644 --- a/brilirs/src/check.rs +++ b/brilirs/src/check.rs @@ -508,6 +508,13 @@ fn type_check_instruction<'a>( } fn type_check_func(bbfunc: &BBFunction, bbprog: &BBProgram) -> Result<(), PositionalInterpError> { + if bbfunc.name == "main" { + if bbfunc.return_type.is_some() { + return Err(InterpError::NonEmptyRetForFunc(bbfunc.name.clone())) + .map_err(|e| e.add_pos(bbfunc.pos.clone())); + } + } + let mut env: FxHashMap<&str, &Type> = FxHashMap::with_capacity_and_hasher(20, fxhash::FxBuildHasher::default()); bbfunc.args.iter().for_each(|a| { diff --git a/brilirs/src/interp.rs b/brilirs/src/interp.rs index 17c5a5596..de8d5fdab 100644 --- a/brilirs/src/interp.rs +++ b/brilirs/src/interp.rs @@ -796,11 +796,6 @@ pub fn execute_main( .map(|i| prog.get(i).unwrap()) .ok_or(InterpError::NoMainFunction)?; - if main_func.return_type.is_some() { - return Err(InterpError::NonEmptyRetForFunc(main_func.name.clone())) - .map_err(|e| e.add_pos(main_func.pos.clone())); - } - let mut env = Environment::new(main_func.num_of_vars); let heap = Heap::default();