Continuing the discussion from SE-0287: Extend implicit member syntax to cover chains of member references:
Saw this in example code from the proposal document referenced in the original thread:
struct Foo {
static var foo = Foo()
var anotherFoo: Foo { Foo() }
func getFoo() -> Foo { Foo() }
var optionalFoo: Foo? { Foo() }
var fooFunc: () -> Foo { { Foo() } }
var optionalFooFunc: () -> Foo? { { Foo() } }
var fooFuncOptional: (() -> Foo)? { { Foo() } }
subscript() -> Foo { Foo() }
}
//...
let _: Foo = .foo[]
I've read over the language grammar part of the Swift PL book several times. The production rules made it seem that, while declaring a subscript
method with zero parameters was legal, calling a subscript with zero arguments was not legal. Have I been misinterpreting the SPL the whole time? Or has the grammar changed at some point to allow this?!
(The example worked for me on Xcode 12 beta 4 on Big Sur public beta.)