hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit e9c32daa3d03dbca69a4beefcfca438f617a91f6
parent c0ff68fb1c7e6d303fc16dfb4f8b8d8e9b57b9ff
Author: Drew DeVault <sir@cmpwn.com>
Date:   Thu,  6 May 2021 09:39:01 -0400

hare::types: simplify resolver error handling

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mhare/types/+test.ha | 2+-
Mhare/types/store.ha | 16+++-------------
2 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/hare/types/+test.ha b/hare/types/+test.ha @@ -39,7 +39,7 @@ fn resolve( rstate: *void, store: *typestore, expr: const *ast::expr, -) (size | deferred | errors::opaque) = { +) (size | deferred | error) = { let expr = expr.expr as ast::constant_expr; let val = expr as lex::value; let ival = val as i64; diff --git a/hare/types/store.ha b/hare/types/store.ha @@ -11,7 +11,7 @@ export type resolver = fn( rstate: *void, store: *typestore, expr: const *ast::expr, -) (size | deferred | errors::opaque); +) (size | deferred | error); export type typestore = struct { // This hash map provides the canonical address for all types owned by @@ -287,12 +287,7 @@ fn list_from_ast( null => return noresolver, r: *resolver => r, }; - const length = match (resolv(store.rstate, store, ex)) { - sz: size => sz, - // TODO: Why can't I propagate this? - deferred => return deferred, - err: errors::opaque => return err, - }; + const length = resolv(store.rstate, store, ex)?; sz = memb.sz * length; assert(sz / length == memb.sz, "overflow"); align = memb.align; @@ -317,12 +312,7 @@ fn _struct_from_ast( *offs = match (membs[i]._offset) { ex: *ast::expr => match (store.resolve) { null => return noresolver, - // TODO: Why can't I propagate this? - res: *resolver => match (res(store.rstate, store, ex)) { - z: size => z, - deferred => return deferred, - err: errors::opaque => return err, - }, + res: *resolver => res(store.rstate, store, ex)?, }, null => *offs, };