@@ -1267,11 +1267,7 @@ impl<A: ASTBuildable> GenericASTLowerer<A> {
12671267
12681268 /// returning `Ok(call)` does not mean the call is valid, just means it is syntactically valid
12691269 /// `ASTLowerer` is designed to cause as little information loss in HIR as possible
1270- pub ( crate ) fn lower_call (
1271- & mut self ,
1272- call : ast:: Call ,
1273- expect : Option < & Type > ,
1274- ) -> LowerResult < hir:: Call > {
1270+ pub ( crate ) fn lower_call ( & mut self , call : ast:: Call , expect : Option < & Type > ) -> hir:: Call {
12751271 log ! ( info "entered {}({}{}(...))" , fn_name!( ) , call. obj, fmt_option!( call. attr_name) ) ;
12761272 let pushed = if let ( Some ( name) , None ) = ( call. obj . get_name ( ) , & call. attr_name ) {
12771273 self . module . context . higher_order_caller . push ( name. clone ( ) ) ;
@@ -1288,7 +1284,7 @@ impl<A: ASTBuildable> GenericASTLowerer<A> {
12881284 self . module . context . higher_order_caller . pop ( ) ;
12891285 }
12901286 errs. extend ( es) ;
1291- return Err ( errs ) ;
1287+ hir :: Expr :: Dummy ( hir :: Dummy :: empty ( ) )
12921288 }
12931289 } ;
12941290 let opt_vi = self . module . context . get_call_t_without_args (
@@ -1375,10 +1371,12 @@ impl<A: ASTBuildable> GenericASTLowerer<A> {
13751371 self . module . context . higher_order_caller . pop ( ) ;
13761372 }
13771373 if errs. is_empty ( ) {
1378- self . exec_additional_op ( & mut call) ?;
1374+ if let Err ( es) = self . exec_additional_op ( & mut call) {
1375+ errs. extend ( es) ;
1376+ }
13791377 }
13801378 self . errs . extend ( errs) ;
1381- Ok ( call)
1379+ call
13821380 }
13831381
13841382 /// importing is done in [preregister](https://github.com/erg-lang/erg/blob/ffd33015d540ff5a0b853b28c01370e46e0fcc52/crates/erg_compiler/context/register.rs#L819)
@@ -2676,14 +2674,27 @@ impl<A: ASTBuildable> GenericASTLowerer<A> {
26762674 ) -> LowerResult < hir:: TypeAscription > {
26772675 log ! ( info "entered {}({tasc})" , fn_name!( ) ) ;
26782676 let kind = tasc. kind ( ) ;
2679- let spec_t = self
2677+ let spec_t = match self
26802678 . module
26812679 . context
2682- . instantiate_typespec ( & tasc. t_spec . t_spec ) ?;
2680+ . instantiate_typespec ( & tasc. t_spec . t_spec )
2681+ {
2682+ Ok ( spec_t) => spec_t,
2683+ Err ( errs) => {
2684+ self . errs . extend ( errs) ;
2685+ Type :: Failure
2686+ }
2687+ } ;
26832688 let expect = expect. map_or ( Some ( & spec_t) , |exp| {
26842689 self . module . context . min ( exp, & spec_t) . ok ( ) . or ( Some ( & spec_t) )
26852690 } ) ;
2686- let expr = self . lower_expr ( * tasc. expr , expect) ?;
2691+ let expr = match self . lower_expr ( * tasc. expr , expect) {
2692+ Ok ( expr) => expr,
2693+ Err ( errs) => {
2694+ self . errs . extend ( errs) ;
2695+ hir:: Expr :: Dummy ( hir:: Dummy :: new ( vec ! [ ] ) )
2696+ }
2697+ } ;
26872698 match kind {
26882699 AscriptionKind :: TypeOf | AscriptionKind :: AsCast => {
26892700 self . module . context . sub_unify (
@@ -2825,7 +2836,7 @@ impl<A: ASTBuildable> GenericASTLowerer<A> {
28252836 ast:: Expr :: Accessor ( acc) => hir:: Expr :: Accessor ( self . lower_acc ( acc, expect) ?) ,
28262837 ast:: Expr :: BinOp ( bin) => hir:: Expr :: BinOp ( self . lower_bin ( bin, expect) ) ,
28272838 ast:: Expr :: UnaryOp ( unary) => hir:: Expr :: UnaryOp ( self . lower_unary ( unary, expect) ) ,
2828- ast:: Expr :: Call ( call) => hir:: Expr :: Call ( self . lower_call ( call, expect) ? ) ,
2839+ ast:: Expr :: Call ( call) => hir:: Expr :: Call ( self . lower_call ( call, expect) ) ,
28292840 ast:: Expr :: DataPack ( pack) => hir:: Expr :: Call ( self . lower_pack ( pack, expect) ?) ,
28302841 ast:: Expr :: Lambda ( lambda) => hir:: Expr :: Lambda ( self . lower_lambda ( lambda, expect) ?) ,
28312842 ast:: Expr :: TypeAscription ( tasc) => {
@@ -2835,7 +2846,7 @@ impl<A: ASTBuildable> GenericASTLowerer<A> {
28352846 // Checking is also performed for expressions in Dummy. However, it has no meaning in code generation
28362847 ast:: Expr :: Dummy ( dummy) => hir:: Expr :: Dummy ( self . lower_dummy ( dummy, expect) ?) ,
28372848 ast:: Expr :: InlineModule ( inline) => {
2838- hir:: Expr :: Call ( self . lower_inline_module ( inline, expect) ? )
2849+ hir:: Expr :: Call ( self . lower_inline_module ( inline, expect) )
28392850 }
28402851 other => {
28412852 log ! ( err "unreachable: {other}" ) ;
@@ -2926,11 +2937,7 @@ impl<A: ASTBuildable> GenericASTLowerer<A> {
29262937 Ok ( hir:: Dummy :: new ( hir_dummy) )
29272938 }
29282939
2929- fn lower_inline_module (
2930- & mut self ,
2931- inline : InlineModule ,
2932- expect : Option < & Type > ,
2933- ) -> LowerResult < hir:: Call > {
2940+ fn lower_inline_module ( & mut self , inline : InlineModule , expect : Option < & Type > ) -> hir:: Call {
29342941 log ! ( info "entered {}" , fn_name!( ) ) ;
29352942 let Some ( ast:: Expr :: Literal ( mod_name) ) = inline. import . args . get_left_or_key ( "Path" ) else {
29362943 unreachable ! ( ) ;
0 commit comments