Problem
Completing properties on a primitive (target., 'abc'., 42.) while paused evaluates enumerateProperties as a string on the call frame using template. Code that will be evaluated is constructed on line 351.
|
if (!objRefResult.result.objectId) { |
|
const primitiveParams = { |
|
...params, |
|
returnByValue: true, |
|
throwOnSideEffect: false, |
|
expression: enumeratePropertiesTemplate.expr( |
|
`(${expression})`, |
|
JSON.stringify(prefix), |
|
JSON.stringify(isInGlobalScope), |
|
), |
|
}; |
|
|
|
const propsResult = await this.evaluator.evaluate( |
|
callFrameId |
|
? { ...primitiveParams, callFrameId } |
|
: { ...primitiveParams, contextId: executionContextId }, |
|
); |
|
|
|
return !propsResult || propsResult.exceptionDetails |
|
? { result: [], isArray: false } |
|
: propsResult.result.value; |
|
} |
The template binds the user expression to its own parameters:
(() => {
let target = (target);
let prefix = "";
let isGlobal = false;
// ... enumerate properties of `target`
})()
If the name being completed is also a parameter or local in that template (target, prefix, isGlobal, or a minified name like n), the inner target refers to the template binding instead of the user variable. Evaluation throws and completions are empty.
This does not affect objects: they are enumerated with Runtime.callFunctionOn on an objectId, so the helper never runs as source in the call frame.
In the currently released version, the following completion won't work because of described error (minified extension sources contain variable named n):
Proposed fix
The first evaluate already returned the primitive. Interpolate that value into the template (let target = 1) and run it with Runtime.evaluate (no call frame). The template no longer reads locals, so names cannot clash.
VS Code Version: 1.134.0
Problem
Completing properties on a primitive (
target.,'abc'.,42.) while paused evaluatesenumeratePropertiesas a string on the call frame using template. Code that will be evaluated is constructed on line 351.vscode-js-debug/src/adapter/completions.ts
Lines 346 to 367 in d17455c
The template binds the user expression to its own parameters:
If the name being completed is also a parameter or local in that template (
target,prefix,isGlobal, or a minified name liken), the inner target refers to the template binding instead of the user variable. Evaluation throws and completions are empty.This does not affect objects: they are enumerated with
Runtime.callFunctionOnon anobjectId, so the helper never runs as source in the call frame.In the currently released version, the following completion won't work because of described error (minified extension sources contain variable named
n):Proposed fix
The first evaluate already returned the primitive. Interpolate that value into the template (
let target = 1) and run it withRuntime.evaluate(no call frame). The template no longer reads locals, so names cannot clash.VS Code Version: 1.134.0