dpscript/ir/validator/checker/
func.rs

1use super::IRChecker;
2use crate::{IRCheckerContext, IRFunction, Result, UnsourcedValidatorError};
3
4impl IRChecker for IRFunction {
5    fn check(&mut self, cx: &mut IRCheckerContext) -> Result<()> {
6        // TODO: Duplicate name checking
7
8        if cx.cur_fn.is_some() {
9            return Err(UnsourcedValidatorError {
10                err: "Functions cannot be nested!".into(),
11            }
12            .into());
13        }
14
15        cx.cur_fn = Some(self.clone());
16
17        for item in &mut self.body {
18            item.check(cx)?;
19        }
20
21        cx.cur_fn = None;
22
23        Ok(())
24    }
25}