check.ha (590B)
1 // SPDX-License-Identifier: MPL-2.0 2 // (c) Hare authors <https://harelang.org> 3 4 use hare::ast; 5 use hare::types; 6 7 // Type checks a set of [[hare::ast::subunit]]s and determines if it is 8 // logically consistent, then returns the corresponding [[unit]], which from 9 // then on is guaranteed to be compilable. 10 export fn check( 11 store: *types::typestore, 12 ident: ast::ident, 13 subunits: const []ast::subunit, 14 ) (unit | error) = { 15 let ctx = context { 16 store = store, 17 scope = alloc(scope { class = scope_class::UNIT, ... }), 18 ... 19 }; 20 scan(&ctx, subunits)?; 21 return process(&ctx, subunits); 22 };