@@ -2620,28 +2620,33 @@ impl Node {
26202620 partials : & mut PartialPaths ,
26212621 symbol_stack : & mut PartialSymbolStack ,
26222622 scope_stack : & mut PartialScopeStack ,
2623- ) {
2623+ ) -> Result < ( ) , PathResolutionError > {
26242624 match self {
26252625 Node :: DropScopes ( _) => { }
26262626 Node :: JumpTo ( _) => { }
26272627 Node :: PopScopedSymbol ( node) => {
26282628 let symbol = symbol_stack
26292629 . pop_front ( partials)
2630- . expect ( "missing symbol for pop scoped symbol node in precondition" ) ;
2631- debug_assert_eq ! ( symbol. symbol, node. symbol) ;
2630+ . ok_or ( PathResolutionError :: EmptySymbolStack ) ?;
2631+ if symbol. symbol != node. symbol {
2632+ return Err ( PathResolutionError :: IncorrectPoppedSymbol ) ;
2633+ }
26322634 * scope_stack = symbol. scopes . into_option ( ) . unwrap ( ) ;
26332635 }
26342636 Node :: PopSymbol ( node) => {
26352637 let symbol = symbol_stack
26362638 . pop_front ( partials)
2637- . expect ( "missing symbol for pop symbol node in precondition" ) ;
2638- debug_assert_eq ! ( symbol. symbol, node. symbol) ;
2639+ . ok_or ( PathResolutionError :: EmptySymbolStack ) ?;
2640+ if symbol. symbol != node. symbol {
2641+ return Err ( PathResolutionError :: IncorrectPoppedSymbol ) ;
2642+ }
26392643 }
26402644 Node :: PushScopedSymbol ( _) => { }
26412645 Node :: PushSymbol ( _) => { }
26422646 Node :: Root ( _) => { }
26432647 Node :: Scope ( _) => { }
2644- }
2648+ } ;
2649+ Ok ( ( ) )
26452650 }
26462651
26472652 /// Ensure the given closed postcondition stacks are half-open for this start node.
@@ -2670,7 +2675,7 @@ impl Node {
26702675 partials : & mut PartialPaths ,
26712676 symbol_stack : & mut PartialSymbolStack ,
26722677 _scope_stack : & mut PartialScopeStack ,
2673- ) {
2678+ ) -> Result < ( ) , PathResolutionError > {
26742679 match self {
26752680 Self :: DropScopes ( _) => { }
26762681 Self :: JumpTo ( _) => { }
@@ -2679,18 +2684,23 @@ impl Node {
26792684 Self :: PushScopedSymbol ( node) => {
26802685 let symbol = symbol_stack
26812686 . pop_front ( partials)
2682- . expect ( "missing symbol for push scoped symbol node in postcondition" ) ;
2683- debug_assert_eq ! ( symbol. symbol, node. symbol) ;
2687+ . ok_or ( PathResolutionError :: EmptySymbolStack ) ?;
2688+ if symbol. symbol != node. symbol {
2689+ return Err ( PathResolutionError :: IncorrectPoppedSymbol ) ;
2690+ }
26842691 }
26852692 Self :: PushSymbol ( node) => {
26862693 let symbol = symbol_stack
26872694 . pop_front ( partials)
2688- . expect ( "missing symbol for push symbol node in postcondition" ) ;
2689- debug_assert_eq ! ( symbol. symbol, node. symbol) ;
2695+ . ok_or ( PathResolutionError :: EmptySymbolStack ) ?;
2696+ if symbol. symbol != node. symbol {
2697+ return Err ( PathResolutionError :: IncorrectPoppedSymbol ) ;
2698+ }
26902699 }
26912700 Self :: Root ( _) => { }
26922701 Self :: Scope ( _) => { }
2693- }
2702+ } ;
2703+ Ok ( ( ) )
26942704 }
26952705
26962706 /// Ensure the given closed postcondition stacks are half-open for this start node.
@@ -2719,23 +2729,32 @@ impl Node {
27192729 paths : & mut Paths ,
27202730 symbol_stack : & mut SymbolStack ,
27212731 _scope_stack : & mut ScopeStack ,
2722- ) {
2732+ ) -> Result < ( ) , PathResolutionError > {
27232733 match self {
27242734 Self :: DropScopes ( _) => { }
27252735 Self :: JumpTo ( _) => { }
27262736 Self :: PopScopedSymbol ( _) => { }
27272737 Self :: PopSymbol ( _) => { }
27282738 Self :: PushScopedSymbol ( node) => {
2729- let symbol = symbol_stack. pop_front ( paths) . unwrap ( ) ;
2730- debug_assert_eq ! ( symbol. symbol, node. symbol) ;
2739+ let symbol = symbol_stack
2740+ . pop_front ( paths)
2741+ . ok_or ( PathResolutionError :: EmptySymbolStack ) ?;
2742+ if symbol. symbol != node. symbol {
2743+ return Err ( PathResolutionError :: IncorrectPoppedSymbol ) ;
2744+ }
27312745 }
27322746 Self :: PushSymbol ( node) => {
2733- let symbol = symbol_stack. pop_front ( paths) . unwrap ( ) ;
2734- debug_assert_eq ! ( symbol. symbol, node. symbol) ;
2747+ let symbol = symbol_stack
2748+ . pop_front ( paths)
2749+ . ok_or ( PathResolutionError :: EmptySymbolStack ) ?;
2750+ if symbol. symbol != node. symbol {
2751+ return Err ( PathResolutionError :: IncorrectPoppedSymbol ) ;
2752+ }
27352753 }
27362754 Self :: Root ( _) => { }
27372755 Self :: Scope ( _) => { }
2738- }
2756+ } ;
2757+ Ok ( ( ) )
27392758 }
27402759}
27412760
@@ -2857,16 +2876,28 @@ impl Path {
28572876 let mut lhs_scope_stack_postcondition = self . scope_stack ;
28582877 let mut rhs_symbol_stack_precondition = partial_path. symbol_stack_precondition ;
28592878 let mut rhs_scope_stack_precondition = partial_path. scope_stack_precondition ;
2860- graph[ self . end_node ] . halfopen_closed_postcondition (
2879+ if let Err ( e ) = graph[ self . end_node ] . halfopen_closed_postcondition (
28612880 paths,
28622881 & mut lhs_symbol_stack_postcondition,
28632882 & mut lhs_scope_stack_postcondition,
2864- ) ;
2865- graph[ partial_path. start_node ] . halfopen_closed_partial_precondition (
2883+ ) {
2884+ panic ! (
2885+ "failed to halfopen postcondition of {}: {:?}" ,
2886+ self . display( graph, paths) ,
2887+ e
2888+ ) ;
2889+ }
2890+ if let Err ( e) = graph[ partial_path. start_node ] . halfopen_closed_partial_precondition (
28662891 partials,
28672892 & mut rhs_symbol_stack_precondition,
28682893 & mut rhs_scope_stack_precondition,
2869- ) ;
2894+ ) {
2895+ panic ! (
2896+ "failed to halfopen precondition of {}: {:?}" ,
2897+ self . display( graph, paths) ,
2898+ e
2899+ ) ;
2900+ } ;
28702901
28712902 let mut symbol_bindings = SymbolStackBindings :: new ( ) ;
28722903 let mut scope_bindings = ScopeStackBindings :: new ( ) ;
@@ -2995,16 +3026,28 @@ impl PartialPath {
29953026 let mut lhs_scope_stack_postcondition = lhs. scope_stack_postcondition ;
29963027 let mut rhs_symbol_stack_precondition = rhs. symbol_stack_precondition ;
29973028 let mut rhs_scope_stack_precondition = rhs. scope_stack_precondition ;
2998- graph[ lhs. end_node ] . halfopen_closed_partial_postcondition (
3029+ if let Err ( e ) = graph[ lhs. end_node ] . halfopen_closed_partial_postcondition (
29993030 partials,
30003031 & mut lhs_symbol_stack_postcondition,
30013032 & mut lhs_scope_stack_postcondition,
3002- ) ;
3003- graph[ rhs. start_node ] . halfopen_closed_partial_precondition (
3033+ ) {
3034+ panic ! (
3035+ "failed to halfopen postcondition of {}: {:?}" ,
3036+ lhs. display( graph, partials) ,
3037+ e
3038+ ) ;
3039+ }
3040+ if let Err ( e) = graph[ rhs. start_node ] . halfopen_closed_partial_precondition (
30043041 partials,
30053042 & mut rhs_symbol_stack_precondition,
30063043 & mut rhs_scope_stack_precondition,
3007- ) ;
3044+ ) {
3045+ panic ! (
3046+ "failed to halfopen postcondition of {}: {:?}" ,
3047+ rhs. display( graph, partials) ,
3048+ e
3049+ ) ;
3050+ } ;
30083051
30093052 let mut symbol_bindings = PartialSymbolStackBindings :: new ( ) ;
30103053 let mut scope_bindings = PartialScopeStackBindings :: new ( ) ;
0 commit comments