@@ -724,15 +724,23 @@ impl PartialSymbolStack {
724724
725725 // CASE 3:
726726 // One of the stacks contains symbols and the other doesn't, and the “empty” stack _does_
727- // have a variable. That means the answer is YES, and the “empty” side's variable needs to
728- // capture the entirety of the non-empty side.
727+ // have a variable. If both sides have the same variable, the answer is NO. Otherwise,
728+ // the answer is YES, and the “empty” side's variable needs to capture the entirety of the
729+ // non-empty side.
729730 //
730731 // lhs rhs
731732 // ============ ============
733+ // (...) $1 (...) $1 => no
732734 // () $1 (stuff) => yes rhs, $1 => rhs
733735 // () $1 (stuff) $2 => yes rhs, $1 => rhs
734736 // (stuff) () $2 => yes lhs, $2 => lhs
735737 // (stuff) $1 () $2 => yes lhs, $2 => lhs
738+ match ( lhs. variable . into_option ( ) , rhs. variable . into_option ( ) ) {
739+ ( Some ( v1) , Some ( v2) ) if v1 == v2 => {
740+ return Err ( PathResolutionError :: ScopeStackUnsatisfied )
741+ }
742+ _ => { }
743+ }
736744 if lhs. contains_symbols ( ) {
737745 let rhs_variable = rhs. variable . into_option ( ) . unwrap ( ) ;
738746 symbol_bindings. add ( partials, rhs_variable, lhs, scope_bindings) ?;
@@ -1095,15 +1103,23 @@ impl PartialScopeStack {
10951103
10961104 // CASE 3:
10971105 // One of the stacks contains scopes and the other doesn't, and the “empty” stack _does_
1098- // have a variable. That means the answer is YES, and the “empty” side's variable needs to
1099- // capture the entirety of the non-empty side.
1106+ // have a variable. If both sides have the same variable, the answer is NO. Otherwise,
1107+ // the answer is YES, and the “empty” side's variable needs to capture the entirety of the
1108+ // non-empty side.
11001109 //
11011110 // lhs rhs
11021111 // ============ ============
1112+ // (...) $1 (...) $1 => no
11031113 // () $1 (stuff) => yes rhs, $1 => rhs
11041114 // () $1 (stuff) $2 => yes rhs, $1 => rhs
11051115 // (stuff) () $2 => yes lhs, $2 => lhs
11061116 // (stuff) $1 () $2 => yes lhs, $2 => lhs
1117+ match ( lhs. variable . into_option ( ) , rhs. variable . into_option ( ) ) {
1118+ ( Some ( v1) , Some ( v2) ) if v1 == v2 => {
1119+ return Err ( PathResolutionError :: ScopeStackUnsatisfied )
1120+ }
1121+ _ => { }
1122+ }
11071123 if lhs. contains_scopes ( ) {
11081124 let rhs_variable = rhs. variable . into_option ( ) . unwrap ( ) ;
11091125 bindings. add ( partials, rhs_variable, lhs) ?;
0 commit comments