About compilation error: "Type of expression is ambiguous without more context"

Hello Swift experts


I have a question that I know you know the answer to. I am writing some classes to build and handle a binary tree node. I think I have completed the task but am kinda unhappy with an error I got and I dont know why it appears. Please check the following sample of code out that reproduces the error, you can use a playground in XCode. I extracted this code from my class and simplified it to reproduce the failuere, so it doesn't follow any logic:


class BinaryTreeNode {
    var data = 0
    var left: BinaryTreeNode? = nil
    var right: BinaryTreeNode? = nil
    init(value: Int) {
        self.data = value
    }
    func getLeftChild() -> BinaryTreeNode? {
        return self.left
    }
}
class BinaryTree {
    var root: BinaryTree?
    func delete(value: Int, inout at root: BinaryTreeNode?) {
        if root != nil {
            var aNode: BinaryTreeNode? = BinaryTreeNode(value: 123)
            var anotherNode: BinaryTreeNode? = BinaryTreeNode(value: 65)
            var aTuple = (current: aNode, parent: anotherNode)
            self.delete(45, at: &aTuple.current!.getLeftChild())
            self.delete(45, at: &aTuple.current!.left)
        }
    }
}


So, in sentence number 20 I keep getting the error message: "Type of expression is ambiguous without more context", but not in sentence 21. I tried some grouping with parenthesis and the error is still there. Any idea what is going on?


I appreciate your help. Kindest regards.


Tomás Balderas

Unfortunately, playgrounds are not that useful yet because of their compilation not being on par with non-playgrounds. I don't know how that's even possible, but if you move into a not-playground, you'll see the actual problem dictated clearly.


getLeftChild is a function.

A function returns an immutable value.

Store the return value in a var before using it.

i am getting the same error when i updated the xcode to the latest version. Not a single error more than 20. But all of them are indicating the same error "Type of expression is ambiguous without more context"

About compilation error: "Type of expression is ambiguous without more context"
 
 
Q