[swift-users] Confused by this error message

Travis Griggs travisgriggs at gmail.com
Mon Jan 30 17:19:20 CST 2017


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.


More information about the swift-users mailing list