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
[SR-13416] Poor diagnostic when referenced struct member doesn't exist #55857
Comments
@swift-ci create |
rmann (JIRA User) Could you please try with the latest master snapshot to see whether this has been fixed already? We made some changes recently to address similar problems. Also it would be great if you could attach the project we could use to reproduce or minimize the example... |
Comment by Rick M (JIRA) @xedin I'm reluctant to add the project to a public DB, but if there's a private place I can put it, I will do that (Apple Radar?). I don't think I can take the time to try it with master, unless it's easy to add to Xcode (it used to be, but I don't see how in Xcode 11). |
rmann (JIRA User) It's pretty easy to add a snapshot from swift.org as a toolchain in Xcode. Installed would put it in the right plot so it could be selected in the Xcode -> Toolchains. Regarding private place - you can file a radar (via Feedback Assistant I think) and attach your sources there. |
Comment by Rick M (JIRA) When I look in Prefs->Components, I only have Simulators, no Toolchains, but the Help says it should be there. Maybe I need to install a toolchain first? BAD UI, APPLE >:o So, swift-DEVELOPMENT-SNAPSHOT-2020-08-18-a-osx.pkg, swift-5.3-DEVELOPMENT-SNAPSHOT-2020-08-18-a-osx.pkg, or is there a more bleeding-edge toolchain I should try? |
Please use `swift-DEVELOPMENT-SNAPSHOT-2020-08-18-a-osx.pkg` one which is a snapshot of trunk. |
Comment by Rick M (JIRA) My project is posted here: https://feedbackassistant.apple.com/feedback/8547655 I think you can just DL the dependencies and try to build it. The file in question is "OrganizationsController.swift", the method is getMachinesErr(). |
Comment by Rick M (JIRA) I can't come anywhere near building my project with swift-DEVELOPMENT-SNAPSHOT-2020-08-18-a-osx.pkg. This is after cleaning the build folder and relaunching Xcode. |
I have used project from feedback and the error I get from the latest main branch snapshot is - `error: value of type 'Organization' has no member 'orgURLName’` which seems to be exactly what is expected. Please try using the latest snapshot to verify and close this issue. |
Attachment: Download
Additional Detail from JIRA
md5: 9d0de4bd604a4ca7f9333bed281168aa
Issue Description:
I've written this Vapor 4 code (in a RouteCollection struct):
The error reported by Swift in Xcode 11.6 (11E708) is "Unable to infer closure type in the current context" with the highlighted section of code being the opening brace on "$0.orgURLName == orgURLName". The actual field name is "urlName", and correcting that in the above code allows it to compile.
The diagnostic message should be more like "No such member `orgURLName`, did you mean `urlName`" with the offending field name highlighted.
Removing the print() and "return" from the closure results in the same diagnostic message, but this time highlighting the opening brace of the guard(else🙂 argument. (when broken up among several lines; when all on one line, it highlights the whole closure).
One additional note: As I was experimenting with this, I changed "$0.urlName" to "$0.asdf" and it gave me a different error, something along the lines of "cannot assign to…". That made me think it was due to the shadowed name "orgURLName", but now I can't get that error to reproduce, regardless of the field name I use.
The text was updated successfully, but these errors were encountered: