-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Conversation
fdb1296
to
deb7aed
Compare
There was a problem hiding this 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) |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also FWIW what we do for CPGETTER_FUNCTION
: https://github.com/emberjs/ember.js/blob/bugfix/assert-when-setting-shadowed-property/packages/@ember/-internals/metal/lib/decorator.ts#L103
deb7aed
to
0b0b1be
Compare
0b0b1be
to
41b68b7
Compare
@rwjblue the issue with local assignment is there's no way for us to intercept that, it's actually impossible to do unfortunately. |
Prevents users from setting a value if it's been shadowed, which can cause inconsistencies in behavior.