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

ergoplatform / sigma-rust / 19957094785

05 Dec 2025 08:23AM UTC coverage: 86.918% (+8.5%) from 78.463%
19957094785

Pull #837

github

web-flow
Merge dec08367a into 2f840d387
Pull Request #837: Split TransactionHintsBag hints properly

44 of 53 new or added lines in 13 files covered. (83.02%)

1621 existing lines in 221 files now uncovered.

27453 of 31585 relevant lines covered (86.92%)

253204.4 hits per line

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

83.33
/ergoscript-compiler/src/type_infer.rs
1
use rowan::TextRange;
2

3
use crate::error::pretty_error_desc;
4
use crate::hir;
5
use crate::hir::Binary;
6
use crate::hir::Expr;
7
use crate::hir::ExprKind;
8

9
#[derive(Debug, PartialEq, Eq)]
10
pub struct TypeInferenceError {
11
    msg: String,
12
    span: TextRange,
13
}
14

15
impl TypeInferenceError {
16
    pub fn new(msg: String, span: TextRange) -> Self {
×
UNCOV
17
        Self { msg, span }
×
UNCOV
18
    }
×
19

20
    pub fn pretty_desc(&self, source: &str) -> String {
×
21
        pretty_error_desc(source, self.span, &self.msg)
×
UNCOV
22
    }
×
23
}
24

25
pub fn assign_type(expr: Expr) -> Result<Expr, TypeInferenceError> {
17✔
26
    hir::rewrite(expr, |e| {
38✔
27
        Ok(match &e.kind {
38✔
28
            ExprKind::Binary(Binary { op, lhs, rhs }) => match op.node {
4✔
29
                hir::BinaryOp::Plus => {
30
                    let l = assign_type(*lhs.clone())?;
4✔
31
                    let r = assign_type(*rhs.clone())?;
4✔
32
                    let tpe = l.tpe.clone();
4✔
33
                    Some(Expr {
4✔
34
                        kind: Binary {
4✔
35
                            op: op.clone(),
4✔
36
                            lhs: l.into(),
4✔
37
                            rhs: r.into(),
4✔
38
                        }
4✔
39
                        .into(),
4✔
40
                        span: e.span,
4✔
41
                        tpe,
4✔
42
                    })
4✔
43
                }
44
                _ => todo!(),
×
45
            },
46
            _ => None,
34✔
47
        })
48
    })
38✔
49
}
17✔
50

51
#[cfg(test)]
52
pub fn check(input: &str, expected_tree: expect_test::Expect) {
1✔
53
    let parse = super::parser::parse(input);
1✔
54
    let syntax = parse.syntax();
1✔
55
    let root = crate::ast::Root::cast(syntax).unwrap();
1✔
56
    let hir = hir::lower(root).unwrap();
1✔
57
    let binder = crate::binder::Binder::new(crate::script_env::ScriptEnv::new());
1✔
58
    let bind = binder.bind(hir).unwrap();
1✔
59
    let res = assign_type(bind).unwrap();
1✔
60
    expected_tree.assert_eq(&res.debug_tree());
1✔
61
}
1✔
62

63
#[cfg(test)]
64
mod tests {
65
    use super::*;
66
    use expect_test::expect;
67

68
    #[test]
69
    fn bin_smoke() {
1✔
70
        check(
1✔
71
            "HEIGHT + HEIGHT",
1✔
72
            expect![[r#"
1✔
73
            Expr {
74
                kind: Binary(
75
                    Binary {
76
                        op: Spanned {
77
                            node: Plus,
78
                            span: 7..8,
79
                        },
80
                        lhs: Expr {
81
                            kind: GlobalVars(
82
                                Height,
83
                            ),
84
                            span: 0..7,
85
                            tpe: Some(
86
                                SInt,
87
                            ),
88
                        },
89
                        rhs: Expr {
90
                            kind: GlobalVars(
91
                                Height,
92
                            ),
93
                            span: 9..15,
94
                            tpe: Some(
95
                                SInt,
96
                            ),
97
                        },
98
                    },
99
                ),
100
                span: 0..15,
101
                tpe: Some(
102
                    SInt,
103
                ),
104
            }"#]],
105
        );
106
    }
1✔
107
}
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