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

Correct build warnings for unneeded default values #1769

Open
jbelkins opened this issue Sep 20, 2024 · 1 comment
Open

Correct build warnings for unneeded default values #1769

jbelkins opened this issue Sep 20, 2024 · 1 comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@jbelkins
Copy link
Contributor

Describe the bug

When building the SDK, the following warnings are thrown:

/Users/jbelkins/Code/Xcode/aws-sdk-swift/Sources/Services/AWSConnect/Sources/AWSConnect/Models.swift:37022:72: warning: left side of nil coalescing operator '??' has non-optional type 'Double', so the right side is never used
37020 |                 return .stringvalue(try reader["StringValue"].read())
37021 |             case "NumericValue":
37022 |                 return .numericvalue(try reader["NumericValue"].read() ?? 0)
      |                                                                        `- warning: left side of nil coalescing operator '??' has non-optional type 'Double', so the right side is never used
37023 |             case "NotApplicable":
37024 |                 return .notapplicable(try reader["NotApplicable"].read() ?? false)

/Users/jbelkins/Code/Xcode/aws-sdk-swift/Sources/Services/AWSConnect/Sources/AWSConnect/Models.swift:37024:74: warning: left side of nil coalescing operator '??' has non-optional type 'Bool', so the right side is never used
37022 |                 return .numericvalue(try reader["NumericValue"].read() ?? 0)
37023 |             case "NotApplicable":
37024 |                 return .notapplicable(try reader["NotApplicable"].read() ?? false)
      |                                                                          `- warning: left side of nil coalescing operator '??' has non-optional type 'Bool', so the right side is never used
37025 |             default:
37026 |                 return .sdkUnknown(name ?? "")

Correct codegen so that deserialization code is not rendered with unnecessary defaults.

Expected Behavior

SDK should build without warnings

Current Behavior

SDK builds with the warnings shown above

Reproduction Steps

Build AWSConnect service
Observe compiler output

Possible Solution

No response

Additional Information/Context

No response

AWS SWIFT SDK version used

1.0.3 / latest

Compiler and Version used

Xcode 16

Operating System and version

macOS 14

@jbelkins jbelkins added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 20, 2024
@jbelkins
Copy link
Contributor Author

jbelkins commented Sep 22, 2024

The warnings are caused by union member targets that have default values.
Union members are non-optional, but we are rendering the code to fill them with the default value applied.

For .numericvalue:

        "com.amazonaws.connect#EvaluationAnswerDataNumericValue": {
            "type": "double",
            "traits": {
                "smithy.api#default": 0
            }
        },

For .notapplicable:

        "com.amazonaws.connect#Boolean": {
            "type": "boolean",
            "traits": {
                "smithy.api#default": false
            }
        },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant