f77b05d464
In assignments the lhs should be evaluated first and shouldn't be re-evaluated when the value of the rhs is available. Fix it by saving the receiver and the key registers into AssignmentLhsData before building the assignment and use them later, instead of visiting the AST again to retrieve the receiver. In addition, now that we save the receiver register, use it to perform the brand check even when we know for sure that it's going to fail later because it's a write to a private method or accessing the accessor in the wrong way (v8:11364), so that the brand check error always appears first if it is present, as specified in https://tc39.es/proposal-private-methods/#sec-privatefieldget Drive-by: unify the brand check error messages, and replace "Object" with "Receiver" in the messages for clarity. The instance private brand check now throws "Receiver must be an instance of class <name>" and the static private brand check now throws "Receiver must be class <name>". Also always set the expression position to the property load position, because the brand check failure comes from the load operation. Bug: v8:12352, v8:11364 Change-Id: I61a8979b2e02b561dd5b2b35f9e0b6691fe07599 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3266964 Commit-Queue: Joyee Cheung <joyee@igalia.com> Reviewed-by: Marja Hölttä <marja@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Igor Sheludko <ishell@chromium.org> Cr-Commit-Position: refs/heads/main@{#77797}
84 lines
2.7 KiB
Plaintext
84 lines
2.7 KiB
Plaintext
Test accessing unused private methods at runtime
|
|
|
|
Running test: testScopesPaused
|
|
Get privateProperties of A in testStatic()
|
|
[
|
|
[0] : {
|
|
name : #staticMethod
|
|
value : {
|
|
className : Function
|
|
description : #staticMethod() { return 1; }
|
|
objectId : <objectId>
|
|
type : function
|
|
}
|
|
}
|
|
]
|
|
Access A.#staticMethod() in testStatic()
|
|
{
|
|
exceptionDetails : {
|
|
columnNumber : 0
|
|
exception : {
|
|
className : ReferenceError
|
|
description : ReferenceError: A is not defined at eval (eval at testStatic (:1:1), <anonymous>:1:1) at Function.testStatic (<anonymous>:6:29) at run (<anonymous>:9:7) at <anonymous>:1:1
|
|
objectId : <objectId>
|
|
subtype : error
|
|
type : object
|
|
}
|
|
exceptionId : <exceptionId>
|
|
lineNumber : 0
|
|
scriptId : <scriptId>
|
|
text : Uncaught
|
|
}
|
|
result : {
|
|
className : ReferenceError
|
|
description : ReferenceError: A is not defined at eval (eval at testStatic (:1:1), <anonymous>:1:1) at Function.testStatic (<anonymous>:6:29) at run (<anonymous>:9:7) at <anonymous>:1:1
|
|
objectId : <objectId>
|
|
subtype : error
|
|
type : object
|
|
}
|
|
}
|
|
Access this.#staticMethod() in testStatic()
|
|
{
|
|
exceptionDetails : {
|
|
columnNumber : 5
|
|
exception : {
|
|
className : Error
|
|
description : Error: Unused static private method '#staticMethod' cannot be accessed at debug time at eval (eval at testStatic (:1:1), <anonymous>:1:6) at Function.testStatic (<anonymous>:6:29) at run (<anonymous>:9:7) at <anonymous>:1:1
|
|
objectId : <objectId>
|
|
subtype : error
|
|
type : object
|
|
}
|
|
exceptionId : <exceptionId>
|
|
lineNumber : 0
|
|
scriptId : <scriptId>
|
|
text : Uncaught
|
|
}
|
|
result : {
|
|
className : Error
|
|
description : Error: Unused static private method '#staticMethod' cannot be accessed at debug time at eval (eval at testStatic (:1:1), <anonymous>:1:6) at Function.testStatic (<anonymous>:6:29) at run (<anonymous>:9:7) at <anonymous>:1:1
|
|
objectId : <objectId>
|
|
subtype : error
|
|
type : object
|
|
}
|
|
}
|
|
get privateProperties of a in testInstance()
|
|
[
|
|
[0] : {
|
|
name : #instanceMethod
|
|
value : {
|
|
className : Function
|
|
description : #instanceMethod() { return 2; }
|
|
objectId : <objectId>
|
|
type : function
|
|
}
|
|
}
|
|
]
|
|
Evaluating this.#instanceMethod() in testInstance()
|
|
{
|
|
result : {
|
|
description : 2
|
|
type : number
|
|
value : 2
|
|
}
|
|
}
|