Kotlin can't compile

Here is the erro: val cannot be reassigned. but It is right on my Editor.

    fun addTwoNumbers(l1: ListNode?, l2: ListNode?): ListNode? {
        var dummy = ListNode(-1)
        var ans = dummy
        var carry = 0
        while (l1 != null || l2 != null) {
            var v1 = 0
            var v2 = 0
            if (l1 == null) v1 = 0 else v1 = l1.`val`
            if (l2 == null) v2 = 0 else v2 = l2.`val`
            var node = ListNode((v1+v2+carry)%10)
            carry = (v1+v2+carry) / 10
            ans.next = node
            ans = node
            
            if(l1 != null) l1 = l1!!.next
            if(l2 != null) l2 = l2!!.next
            // l1 = if (l1 == null) null else l1!!.next
            // l2 = if (l2 == null) null else l2!!.next
        }
        
        if(carray!=0) ans.next = ListNode(carray)
            
        
        return dummy.next
    }
Comments (1)