Skip to content

Arguments sometimes not checked or evaluated because of defaults #1610

Open
@OliveIsAWord

Description

fn foo(a: u32 = 123456, b: u32) {
    println("a={}, b={}", a, b)
}

fn main() {
    foo(a: 123, b: 456) // Prints "a=123, b=456" as expected.
    foo(b: 456, a: 123) // Prints "a=123456, b=456". What?
    foo(b: 456, real_arg: abort() - real_var) // Wait, this argument is completely ignored!
}

Function overload resolution seems to catch all the errors if the call has too many arguments.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions