• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TyRoXx / NonlocalityOS / 14826269493

04 May 2025 11:33PM UTC coverage: 73.084% (-0.05%) from 73.132%
14826269493

push

github

TyRoXx
Test nested tree construction

3109 of 4254 relevant lines covered (73.08%)

2284.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.86
/lambda_compiler/src/type_checking.rs
1
use crate::{ast, compilation::CompilerOutput};
2
use astraea::{
3
    storage::{StoreError, StoreTree},
4
    tree::{HashedTree, Tree},
5
};
6
use std::sync::Arc;
7

8
pub async fn check_types(
30✔
9
    syntax_tree: &ast::Expression,
10
    storage: &dyn StoreTree,
11
) -> Result<CompilerOutput, StoreError> {
12
    match syntax_tree {
30✔
13
        ast::Expression::Identifier(name) => Ok(CompilerOutput::new(
6✔
14
            Some(lambda::expressions::DeepExpression(
6✔
15
                lambda::expressions::Expression::ReadVariable(name.clone()),
6✔
16
            )),
17
            Vec::new(),
6✔
18
        )),
19
        ast::Expression::StringLiteral(value) => Ok(CompilerOutput::new(
12✔
20
            Some(lambda::expressions::DeepExpression(
21
                lambda::expressions::Expression::Literal(
22
                    storage
6✔
23
                        .store_tree(&HashedTree::from(Arc::new(
6✔
24
                            Tree::from_string(value).unwrap(/*TODO*/),
6✔
25
                        )))
26
                        .await?,
6✔
27
                ),
28
            )),
29
            Vec::new(),
30
        )),
31
        ast::Expression::Apply { callee, argument } => {
2✔
32
            let callee_output = Box::pin(check_types(callee, storage)).await?;
4✔
33
            let argument_output = Box::pin(check_types(argument, storage)).await?;
2✔
34
            let errors = callee_output
35
                .errors
36
                .into_iter()
37
                .chain(argument_output.errors)
38
                .collect();
39
            match (callee_output.entry_point, argument_output.entry_point) {
40
                (Some(callee_checked), Some(argument_checked)) => Ok(CompilerOutput {
2✔
41
                    entry_point: Some(lambda::expressions::DeepExpression(
2✔
42
                        lambda::expressions::Expression::Apply {
2✔
43
                            callee: Arc::new(callee_checked),
2✔
44
                            argument: Arc::new(argument_checked),
2✔
45
                        },
46
                    )),
47
                    errors: errors,
2✔
48
                }),
49
                (None, _) | (_, None) => return Ok(CompilerOutput::new(None, errors)),
×
50
            }
51
        }
52
        ast::Expression::Lambda {
53
            parameter_name,
10✔
54
            body,
10✔
55
        } => {
56
            let body_output = Box::pin(check_types(body, storage)).await?;
20✔
57
            match body_output.entry_point {
58
                Some(body_checked) => Ok(CompilerOutput {
10✔
59
                    entry_point: Some(lambda::expressions::DeepExpression(
10✔
60
                        lambda::expressions::Expression::Lambda {
10✔
61
                            parameter_name: parameter_name.clone(),
10✔
62
                            body: Arc::new(body_checked),
10✔
63
                        },
64
                    )),
65
                    errors: body_output.errors,
10✔
66
                }),
67
                None => return Ok(CompilerOutput::new(None, body_output.errors)),
×
68
            }
69
        }
70
        ast::Expression::ConstructTree(expressions) => {
6✔
71
            let mut errors = Vec::new();
6✔
72
            let mut children = Vec::new();
6✔
73
            for expression in expressions {
18✔
74
                let output = Box::pin(check_types(expression, storage)).await?;
12✔
75
                errors.extend(output.errors);
76
                if let Some(checked) = output.entry_point {
6✔
77
                    children.push(Arc::new(checked));
78
                } else {
79
                    return Ok(CompilerOutput::new(None, errors));
×
80
                }
81
            }
82
            Ok(CompilerOutput {
6✔
83
                entry_point: Some(lambda::expressions::DeepExpression(
6✔
84
                    lambda::expressions::Expression::ConstructTree(children),
6✔
85
                )),
86
                errors: errors,
6✔
87
            })
88
        }
89
    }
90
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc