title: swift LLDB produces correct results, but different results from code execution
body: <p>I'm experiencing a weird behavior... </p>
  
  <p>In short - running this command (on a <code>Range&lt;Index&gt;</code> ) within an application code</p>
  
  <pre><code>currIndexPlaceA = a!.startIndex.successor()..&lt;newText.endIndex;
  </code></pre>
  
  <p>is ignored...</p>
  
  <p>When I set a breakpoint after this command, and run <code>po a</code> in the debug window (lldb), I get:</p>
  
  <blockquote>
    <p>▿ Optional>   ▿ Some : Range(39..&lt;44)
        - startIndex : 39
        - endIndex : 44</p>
  </blockquote>
  
  <p>while <code>po currIndexPlaceA</code> is:</p>
  
  <blockquote>
    <p>▿ Range(5..&lt;54)
      - startIndex : 5
      - endIndex : 54</p>
  </blockquote>
  
  <p>it is clear that startIndex should have been higher than 39!</p>
  
  <p>but, running the same command through the lldb window:</p>
  
  <pre><code>expr currIndexPlaceA = a!.startIndex.successor()..&lt;newText.endIndex;
  </code></pre>
  
  <p>results in (<code>po currIndexPlaceA</code>):</p>
  
  <blockquote>
    <p>▿ Range(40..&lt;54)
      - startIndex : 40
      - endIndex : 54</p>
  </blockquote>
  
  <p>What's going on here?????</p>
  
  <p>If you want to debug my full function.. it's kind of a headache - it's a sort of xml parser... </p>
  
  <p>I test it with text: <code>&lt;id&gt;&lt;id&gt;&lt;/id&gt;&lt;id/&gt;&lt;id /&gt;&lt;id&gt;&lt;id /&gt;&lt;id/&gt;&lt;id&gt;&lt;/id&gt;&lt;/id&gt;&lt;/id&gt;</code></p>
  
  <p>and tagName: <code>id</code></p>
  
  <pre><code>func getTagContent(text : String, tagName : String) -&gt; [String!]!{
          // Extracts reply
          var newText = text;
          var currProcessing = text;
          var retVal = [String!]();
          while (newText != ""){
              let rangeFirst = newText.rangeOfString("&lt;" + tagName, options: [], range: nil, locale: nil);
              if let actrange = rangeFirst
              {
                  newText = newText.substringFromIndex(actrange.startIndex.advancedBy(tagName.characters.count + 1));
  
                  let rangeEndFirstTag = newText.rangeOfString("&gt;");
                  if let actRangeEndFirstTab = rangeEndFirstTag {
                      let distToCloseTag = newText.startIndex.distanceTo(actRangeEndFirstTab.startIndex)
                      if (distToCloseTag == 0 || (distToCloseTag &gt; 0 &amp;&amp; newText[actRangeEndFirstTab.startIndex.predecessor()] != "/")) {
                          newText = newText.substringFromIndex(actRangeEndFirstTab.startIndex.advancedBy(1));
  
                          var currIndexPlaceA = newText.startIndex..&lt;newText.endIndex;
                          var currIndexPlaceB = newText.startIndex..&lt;newText.endIndex;
                          var a = newText.rangeOfString("&lt;/" + tagName + "&gt;", options: NSStringCompareOptions.LiteralSearch, range: currIndexPlaceA, locale: nil);
                          if a == nil {a = newText.rangeOfString("&lt;/" + tagName + " ", options: NSStringCompareOptions.LiteralSearch, range: currIndexPlaceA, locale: nil);}
                          var b = newText.rangeOfString("&lt;" + tagName + "&gt;", options: NSStringCompareOptions.LiteralSearch, range: currIndexPlaceB, locale: nil);
                          if b == nil {b = newText.rangeOfString("&lt;" + tagName + " ", options: NSStringCompareOptions.LiteralSearch, range: currIndexPlaceB, locale: nil);}
  
                          while (a != nil &amp;&amp; b != nil &amp;&amp; b?.startIndex &lt; a?.startIndex){
                              let txt = newText.substringFromIndex(b!.endIndex);
                              var closedTag = false;
                              if let tmpRagne = txt.rangeOfString("&gt;"){
                                  if (tmpRagne.startIndex &gt; txt.startIndex){
                                      if (txt[tmpRagne.startIndex.predecessor()] == "/"){
                                          closedTag = true;
                                      }
                                  }
                              }
  
                              if closedTag{
                                  currIndexPlaceB = b!.startIndex.successor()..&lt;newText.endIndex;
                                  var b = newText.rangeOfString("&lt;" + tagName + "&gt;", options: NSStringCompareOptions.LiteralSearch, range: currIndexPlaceB, locale: nil);
                                  if b == nil {b = newText.rangeOfString("&lt;" + tagName + " ", options: NSStringCompareOptions.LiteralSearch, range: currIndexPlaceB, locale: nil);}
                              }
                              else{
                                  currIndexPlaceA = a!.startIndex.successor()..&lt;newText.endIndex;
                                  currIndexPlaceB = b!.startIndex.successor()..&lt;newText.endIndex;
  
                                  var a = newText.rangeOfString("&lt;/" + tagName + "&gt;", options: NSStringCompareOptions.LiteralSearch, range: currIndexPlaceA, locale: nil);
                                  if a == nil {a = newText.rangeOfString("&lt;/" + tagName + " ", options: NSStringCompareOptions.LiteralSearch, range: currIndexPlaceA, locale: nil);}
                                  var b = newText.rangeOfString("&lt;" + tagName + "&gt;", options: NSStringCompareOptions.LiteralSearch, range: currIndexPlaceB, locale: nil);
                                  if b == nil {b = newText.rangeOfString("&lt;" + tagName + " ", options: NSStringCompareOptions.LiteralSearch, range: currIndexPlaceB, locale: nil);}
                              }
                          }
                          if a == nil { return nil; }
  
  
                          currProcessing = newText.substringToIndex(a!.startIndex);
                          retVal.append(currProcessing);
                          newText = newText.substringFromIndex(a!.startIndex.successor());
                          if let lastRange = newText.rangeOfString("&gt;"){
                              newText = newText.substringFromIndex(lastRange.endIndex);
                          }
                          else {
                              return nil;
                          }
  
                      }
                      else{
                          newText = newText.substringFromIndex(actRangeEndFirstTab.startIndex.successor());
                          retVal.append(nil);
                      }
                  }
              }
              else {
                  break;
              }
          }
  
  
          return retVal;
      }
  </code></pre>