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

[BUGFIX] Asserts when users attempt to set a shadowed value with Ember.set #19198

Merged
merged 1 commit into from
Oct 16, 2020

Conversation

pzuraq
Copy link
Contributor

@pzuraq pzuraq commented Oct 13, 2020

Prevents users from setting a value if it's been shadowed, which can cause inconsistencies in behavior.

@pzuraq pzuraq force-pushed the bugfix/assert-when-setting-shadowed-property branch from fdb1296 to deb7aed Compare October 15, 2020 02:01
Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think asserting in Ember.set is enough? Wouldn't folks also assume a local assignment works (no set) and not hit this error?

`Attempted to set \`${toString(
obj
)}.${keyName}\` using Ember.set(), but the property was a computed or tracked property that was shadowed by another property declaration. This can happen if you defined a tracked or computed property on a parent class, and then redefined it on a subclass.`,
name && (name.indexOf('CPSETTER_FUNCTION') !== -1 || name.indexOf('TRACKED_SETTER') !== -1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of indexing the name can we keep the weakset system (for debug only)?

Copy link
Contributor Author

@pzuraq pzuraq Oct 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can, it's just more of a pain to maintain. FWIW, this is what we did before we actually needed to rely on the behavior in prod

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pzuraq pzuraq force-pushed the bugfix/assert-when-setting-shadowed-property branch from deb7aed to 0b0b1be Compare October 15, 2020 15:29
@pzuraq pzuraq force-pushed the bugfix/assert-when-setting-shadowed-property branch from 0b0b1be to 41b68b7 Compare October 15, 2020 15:45
@pzuraq
Copy link
Contributor Author

pzuraq commented Oct 15, 2020

@rwjblue the issue with local assignment is there's no way for us to intercept that, it's actually impossible to do unfortunately.

@rwjblue rwjblue merged commit e8d15e8 into master Oct 16, 2020
@rwjblue rwjblue deleted the bugfix/assert-when-setting-shadowed-property branch October 16, 2020 16:48
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.

2 participants