Skip to content

Commit

Permalink
fix: error when processing private properties with a map (#1825)
Browse files Browse the repository at this point in the history
Fixes #1824
  • Loading branch information
connor4312 authored Sep 28, 2023
1 parent eb98953 commit 0799535
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he

## Nightly (only)

Nothing, yet
- fix: error when processing private properties with a map ([#1824](https://github.com/microsoft/vscode-js-debug/issues/1824))

## v1.83 (September 2023)

Expand Down
6 changes: 3 additions & 3 deletions src/adapter/variableStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,9 +854,9 @@ class SetOrMapVariable extends ObjectVariable {

constructor(context: VariableContext, remoteObject: Cdp.Runtime.RemoteObject) {
super(context, remoteObject, NoCustomStringRepr);
const cast = remoteObject.preview as MapPreview | SetPreview;
this.isMap = cast.subtype === 'map';
this.size = Number(cast.properties.find(p => p.name === 'size')?.value) ?? undefined;
this.isMap = remoteObject.subtype === 'map';
const cast = remoteObject.preview as MapPreview | SetPreview | undefined;
this.size = Number(cast?.properties.find(p => p.name === 'size')?.value) ?? undefined;
}

public override async toDap(previewContext: PreviewContextType): Promise<Dap.Variable> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> result: A {#bar: Map(1)}
> #bar: Map(1)
> [[Prototype]]: Object
8 changes: 8 additions & 0 deletions src/test/variables/variablesTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,14 @@ describe('variables', () => {
});
});

itIntegrates('map variable without preview (#1824)', async ({ r }) => {
const p = await r.launchAndLoad('blank');
await p.logger.evaluateAndLog(`
class A { #bar = new Map([[1, 2]]) }
new A();`);
p.assertLog();
});

itIntegrates('readMemory/writeMemory', async ({ r }) => {
const p = await r.launchAndLoad('blank');
p.cdp.Runtime.evaluate({
Expand Down

0 comments on commit 0799535

Please sign in to comment.