Skip to content
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

Generated code produces compile error when accessing "data" dictionary in the "InputDict" struct if the name of the accessed property is "hash" #2603

Closed
Anteo95 opened this issue Oct 24, 2022 · 4 comments · Fixed by #2607
Assignees
Labels
bug Generally incorrect behavior codegen Issues related to or arising from code generation
Milestone

Comments

@Anteo95
Copy link
Contributor

Anteo95 commented Oct 24, 2022

Bug report

Currently there is a compiler error in generated code when accessing "data" dictionary in the "InputDict" struct if the name of the accessed property is "hash".

Versions

  • apollo-ios SDK version: 1.0.2
  • Xcode version: 14.1 RC
  • Swift version: 5.7.1

Steps to reproduce

  1. execute generate code command.

Further details

Here is a screenshot of errors produced by the compiler:

Screenshot 2022-10-24 at 15 38 55

I think the reason why this fails is because InputDict has a function:

  public func hash(into hasher: inout Hasher) {
    hasher.combine(data._jsonEncodableValue?._jsonValue)
  }

and that causes the compiler to not be able to find "hash" field through dynamic member lookup.

changing generated code to this removes the compile error:

Screenshot 2022-10-24 at 15 44 13

If there is need for any additional info for solving this issue I will try to answer it here.

@calvincestari
Copy link
Member

Hi @Anteo95 👋🏻 - thanks for the bug report. I'll do some more investigation but this looks like another parameter name we'll need to escape or mark as reserved.

@calvincestari calvincestari added the bug Generally incorrect behavior label Oct 24, 2022
@calvincestari calvincestari added the codegen Issues related to or arising from code generation label Oct 24, 2022
@calvincestari
Copy link
Member

calvincestari commented Oct 25, 2022

@Anteo95 thanks your solution. I tried many different things yesterday and it looks like that is the only viable one to fix it completely. It's particularly bothersome that the hash function is not something internal that we could simply rename.

@Anteo95
Copy link
Contributor Author

Anteo95 commented Oct 26, 2022

@calvincestari no problem, glad I could help!

@calvincestari
Copy link
Member

This issue is fixed with the merging of #2607 and will be included with the 1.0.3 release soon.

@Anteo95 I ended up simply removing @dynamicMemberLookup, which made the solution far easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Generally incorrect behavior codegen Issues related to or arising from code generation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants