Confused by this error message

I’m currently refactoring some code (Swift 3.?, latest XCode), and I ended up with the following:

  func spansTSON() -> TSON {
    var docs = self.spans.map() { $0.tson }
    for (span, doc) in zip(self.spans, docs) {
      if let datum = span.begin.datum {
        if let index = self.spans.index(where: {return $0.includesAnchor(datum)}) {
          doc["datum"] = (index * 2 + (datum.isBegin ? 0 : 1)).tson
        }
      }
    }
    return TSON.array(docs)
  }

The vague error I get is “Ambiguous reference to spans” on the “if let index = self.spans…” line with the “self” highlighted. The container is a class. “spans” is computed property. I’m not sure if it’s confused about what self is, or spans. Or why either wouldn’t be clear.

Nevermind.

I had a few moments before added a setter function that looked like func spans(tson:TSON)

···

On Jan 30, 2017, at 3:19 PM, Travis Griggs <travisgriggs@gmail.com> wrote:

I’m currently refactoring some code (Swift 3.?, latest XCode), and I ended up with the following:

  func spansTSON() -> TSON {
    var docs = self.spans.map() { $0.tson }
    for (span, doc) in zip(self.spans, docs) {
      if let datum = span.begin.datum {
        if let index = self.spans.index(where: {return $0.includesAnchor(datum)}) {
          doc["datum"] = (index * 2 + (datum.isBegin ? 0 : 1)).tson
        }
      }
    }
    return TSON.array(docs)
  }

The vague error I get is “Ambiguous reference to spans” on the “if let index = self.spans…” line with the “self” highlighted. The container is a class. “spans” is computed property. I’m not sure if it’s confused about what self is, or spans. Or why either wouldn’t be clear.