-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in grammar regarding in-out-expression #193
Open
Labels
Content issue
A problem in with the book's prose, code, or figures
Comments
amartini51
added
the
Content issue
A problem in with the book's prose, code, or figures
label
Oct 10, 2023
Thanks! This change looks like it's probably correct, but I'll need to find someone who can tech review to confirm this is exactly the expected behavior. |
No problem. Thanks for the reply! |
Keeping this issue open while we discuss a better fix in #194 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Location
https://github.com/apple/swift-book/blob/main/TSPL.docc/ReferenceManual/Expressions.md?plain=1#L64
Description
An in-out-expression is defined as being & identifier.
This is incorrect, and can be seen on line 51 that it's meant to be & expression. (here: https://github.com/apple/swift-book/blob/main/TSPL.docc/ReferenceManual/Expressions.md?plain=1#L51)
I'm assuming this is just a simple error that was overlooked but I will leave a demonstration below of why the version with identifier isn't correct.
Given this example program:
This is compliable code in swiftc.
Our point of concern is the use of an in-out expression as a parameter in the call to myFunc
There is no possible derivation of this subsection of the code given the production for in-out-expression with identifier rather than expression.
Let us look at some possible derivation paths for
myFunc(&s.a)
Possible derivation path: (terminals in bold)
???- cannot reach a production that will get us &s
Let's look at another possible derivation path.
Picking up from step 12 in the above derivation:
12) -> myFunc ( prefix-expression infix-expressions? )
13) -> myFunc ( in-out-expression infix-expressions? )
14) -> myFunc ( & identifier infix-expressions? )
15) -> myFunc ( & ??? infix-expressions? )
???- cannot reach a production that will get us &s.a
Correction
Line 64 should read in-out-expression →
&
expressionThe text was updated successfully, but these errors were encountered: