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

Suppress unhelpful warnings on Ruby 2.7 #112

Merged
merged 1 commit into from
Jun 24, 2021
Merged

Suppress unhelpful warnings on Ruby 2.7 #112

merged 1 commit into from
Jun 24, 2021

Conversation

clowder
Copy link
Contributor

@clowder clowder commented Jun 23, 2021

Calling [Attribute#default_value] on record initialized with a
:default_value triggered the following warning:

instance variable @default_value_or_lambda not initialized

The warning's not particularly useful as the caller will simply get a
nil and carry on anyway[1]. By setting the variable to nil for
records without a :default_value we maintain this behaviour and
suppress the warning.

[1]: Later versions of Ruby simply suppress this warning

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Calling `[Attribute#default_value]` on record initialized with a
`:default_value` triggered the following warning:

```
instance variable @default_value_or_lambda not initialized
```

The warning's not particularly useful as the caller will simply get a
`nil` and carry on anyway[1]. By setting the variable to `nil` for
records without a `:default_value` we maintain this behaviour and
suppress the warning.

[1]: Later versions of Ruby simply suppress this warning
@alextwoods
Copy link
Contributor

These look good - thanks for submitting!

@alextwoods alextwoods merged commit fde8b61 into aws:main Jun 24, 2021
lsglick added a commit to lsglick/aws-sdk-ruby-record that referenced this pull request Sep 25, 2023
The fix in aws#112 had the side effect of calling `type_cast` on `nil` if the `default_value` was unset or explicitly set to `nil`.

Because the `StringSetMarshaler` and `NumericSetMarshaler` both convert `nil` to `Set.new`, this caused the default value in practice to become `Set.new` instead of `nil`.

Ultimately this caused downstream effects such as always persisting empty or unset sets as `nil` despite the `#persist_nil?` returning `false`.
lsglick added a commit to lsglick/aws-sdk-ruby-record that referenced this pull request Sep 25, 2023
The fix in aws#112 had the side effect of calling `type_cast` on `nil` if the `default_value` was unset.

Because the `StringSetMarshaler` and `NumericSetMarshaler` both convert `nil` to `Set.new`, this caused the unset default value in practice to become `Set.new` instead of `nil`.

Ultimately this caused downstream effects such as always persisting empty or unset sets as `nil` despite the `#persist_nil?` returning `false`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants