Argument labels and parameter names: differences locally and on this site

I’ve completed the Windowing System exercise on the Swift track and found that my local Swift testing (Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4) appears to require function argument labels and parameter names, but the test suite on the Exercism doesn’t.

Apple’s documentation says “By default, parameters use their parameter name as their argument label.”, so I’m not exactly sure what’s going on with this behavior.

As an example, this is the code that passes the test on the site:

struct Position {
    var x = 0
    var y = 0
    
    mutating func moveTo(newX: Int, newY: Int) { // <- no names here
        x = newX
        y = newY
    }
}

However, this fails on my local machine with “error: missing argument labels ‘newX:newY:’ in pos.moveTo(newX, newY)”

If I change the code to this on my local machine, it passes (note the underscore argument labels on the mutating func line)

struct Position {
    var x = 0
    var y = 0
    
    mutating func moveTo(_ newX: Int, _ newY: Int) {
        x = newX
        y = newY
    }
}

Is this expected? Is it a version difference? Is there some configuration setting that affects this? Just curious why my local environment behaves differently from the Exercism testing environment.

Thanks.

Looks like that track is using Swift 5.8 so it probably is a version difference. I don’t speak Swift, but I’m guessing the argument labels became mandatory between the two versions.

To be honest I am not sure why it differs, I haven’t played around with any of the recent Swift versions so I am not sure if they changed something, but the behavior on your local machine looks a bit odd, but I can’t explain it.

Updating the swift test runner to a new version is a huge body of work, I might to do it at some point but currently, I am not feeling it, since it involves more or less a complete rewrite. I did update the test runner from swift 5.3 to 5.8. But we will likely at some point update the test runner, the new swift testing framework is interesting, however, I would like more information in the output data it gives. It is likely something that will evolve throughout the coming swift versions.

1 Like

Thanks to both for the replies. It’s still a mystery, but now that I know what’s happening I can work with it. I checked on the changes from Swift 5 to 6 and don’t see anything obvious that would cause this behavior.