Should there be any errors at all here?
(If so, the error messages should probably refer to the previous declaration (the one being redeclared) rather than the attempted but disallowed redeclaration, right?)
func f() {
print("Hi")
}
let f: Int = 123 // ERR: Invalid redeclaration of `f`
struct S {
let v = 456
func v() { // ERR: Invalid redeclaration of `v()`
print("Hey!")
}
}
There is the same behavior with enum cases and enum members:
enum Foo {
case a
func a() {} // error: invalid redeclaration of 'a()'
}
You may ask why? Then look at this example where you can extract the instance method:
enum Bar {
case a
func b() {
print("BAR")
}
}
let getBFromBar: (Bar) -> (() -> Void) = Bar.b
let b: () -> Void = getBFromBar(Bar.a) // or `Bar.a.b`
b() // prints "BAR"
If you had a b case instead it would become ambiguous to the compiler.