Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Mutability compatibility issue on call-site vs args #48

@amanjeev

Description

@amanjeev

Problem code

fun main() {
    fib(0, 1, 10)
}

fun fib(mut first: i64, mut second: i64, mut limit: i64) {
    println(first)
    println(second)

    mut next = first + second
    first = second
    second = next
    limit -= 1
    
    fib(first, second, limit)
}

Output

───┬─ main/main.june:2:9
 1 │ fun main() {
 2 │     fib(0, 1, 10)
   │         ╍ error: argument to function needs to be mutable
 3 │ }
───┴─

Expected output

No error, the call site should just pass integers and fib should take care of the mutability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions