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

fix(node): Record local variables with falsy values (v7) #11190

Merged
merged 2 commits into from Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -20,6 +20,9 @@ function one(name) {
name,
num: 5,
};
const bool = false;
const num = 0;
const str = '';

const ty = new Some();

Expand Down
Expand Up @@ -22,6 +22,9 @@ function one(name) {
functionsShouldNotBeIncluded: () => {},
functionsShouldNotBeIncluded2() {},
};
const bool = false;
const num = 0;
const str = '';

const ty = new Some();

Expand Down
Expand Up @@ -22,6 +22,9 @@ function one(name) {
name,
num: 5,
};
const bool = false;
const num = 0;
const str = '';

const ty = new Some();

Expand Down
Expand Up @@ -24,6 +24,9 @@ function one(name) {
name,
num: 5,
};
const bool = false;
const num = 0;
const str = '';

const ty = new Some();

Expand Down
Expand Up @@ -23,6 +23,9 @@ function one(name) {
name,
num: 5,
};
const bool = false;
const num = 0;
const str = '';

const ty = new Some();

Expand Down
Expand Up @@ -16,6 +16,9 @@ const EXPECTED_LOCAL_VARIABLES_EVENT = {
arr: [1, '2', null],
obj: { name: 'some name', num: 5 },
ty: '<Some>',
bool: false,
num: 0,
str: '',
},
}),
expect.objectContaining({
Expand Down
Expand Up @@ -42,9 +42,9 @@ async function unrollObject(session: Session, objectId: string, name: string, va
}

function unrollOther(prop: Runtime.PropertyDescriptor, vars: Variables): void {
if (prop?.value?.value) {
if (prop?.value?.value != null) {
vars[prop.name] = prop.value.value;
} else if (prop?.value?.description && prop?.value?.type !== 'function') {
} else if (prop?.value?.description != null && prop?.value?.type !== 'function') {
vars[prop.name] = `<${prop.value.description}>`;
}
}
Expand All @@ -63,7 +63,7 @@ async function getLocalVariables(session: Session, objectId: string): Promise<Va
} else if (prop?.value?.objectId && prop?.value?.className === 'Object') {
const id = prop.value.objectId;
await unrollObject(session, id, prop.name, variables);
} else if (prop?.value?.value || prop?.value?.description) {
} else if (prop?.value?.value != null || prop?.value?.description != null) {
unrollOther(prop, variables);
}
}
Expand Down
Expand Up @@ -129,7 +129,7 @@ class AsyncSession implements DebugSession {
} else if (prop?.value?.objectId && prop?.value?.className === 'Object') {
const id = prop.value.objectId;
add(vars => this._unrollObject(id, prop.name, vars, next));
} else if (prop?.value?.value || prop?.value?.description) {
} else if (prop?.value?.value != null || prop?.value?.description != null) {
add(vars => this._unrollOther(prop, vars, next));
}
}
Expand Down Expand Up @@ -192,9 +192,9 @@ class AsyncSession implements DebugSession {
* Unrolls other properties
*/
private _unrollOther(prop: Runtime.PropertyDescriptor, vars: Variables, next: (vars: Variables) => void): void {
if (prop?.value?.value) {
if (prop?.value?.value != null) {
vars[prop.name] = prop.value.value;
} else if (prop?.value?.description && prop?.value?.type !== 'function') {
} else if (prop?.value?.description != null && prop?.value?.type !== 'function') {
vars[prop.name] = `<${prop.value.description}>`;
}

Expand Down