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

TyRoXx / NonlocalityOS / 14825942646

04 May 2025 10:48PM UTC coverage: 73.166% (+0.03%) from 73.132%
14825942646

Pull #237

github

web-flow
Merge adddf5a39 into 34f1d88fd
Pull Request #237: Tree literal

30 of 35 new or added lines in 3 files covered. (85.71%)

15 existing lines in 1 file now uncovered.

3092 of 4226 relevant lines covered (73.17%)

2252.58 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(
20✔
9
    syntax_tree: &ast::Expression,
10
    storage: &dyn StoreTree,
11
) -> Result<CompilerOutput, StoreError> {
12
    match syntax_tree {
20✔
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(
6✔
20
            Some(lambda::expressions::DeepExpression(
21
                lambda::expressions::Expression::Literal(
22
                    storage
3✔
23
                        .store_tree(&HashedTree::from(Arc::new(
3✔
24
                            Tree::from_string(value).unwrap(/*TODO*/),
3✔
25
                        )))
26
                        .await?,
3✔
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,
7✔
54
            body,
7✔
55
        } => {
56
            let body_output = Box::pin(check_types(body, storage)).await?;
14✔
57
            match body_output.entry_point {
58
                Some(body_checked) => Ok(CompilerOutput {
7✔
59
                    entry_point: Some(lambda::expressions::DeepExpression(
7✔
60
                        lambda::expressions::Expression::Lambda {
7✔
61
                            parameter_name: parameter_name.clone(),
7✔
62
                            body: Arc::new(body_checked),
7✔
63
                        },
64
                    )),
65
                    errors: body_output.errors,
7✔
66
                }),
67
                None => return Ok(CompilerOutput::new(None, body_output.errors)),
×
68
            }
69
        }
70
        ast::Expression::ConstructTree(expressions) => {
2✔
71
            let mut errors = Vec::new();
2✔
72
            let mut children = Vec::new();
2✔
73
            for expression in expressions {
6✔
74
                let output = Box::pin(check_types(expression, storage)).await?;
4✔
75
                errors.extend(output.errors);
76
                if let Some(checked) = output.entry_point {
2✔
77
                    children.push(Arc::new(checked));
78
                } else {
NEW
79
                    return Ok(CompilerOutput::new(None, errors));
×
80
                }
81
            }
82
            Ok(CompilerOutput {
2✔
83
                entry_point: Some(lambda::expressions::DeepExpression(
2✔
84
                    lambda::expressions::Expression::ConstructTree(children),
2✔
85
                )),
86
                errors: errors,
2✔
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