Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed May 27, 2022
1 parent b3fa3f5 commit b5cd46e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
5 changes: 3 additions & 2 deletions src/ast/nodes/BinaryExpression.ts
Expand Up @@ -40,9 +40,10 @@ const binaryOperators: {
'>>': (left: any, right: any) => left >> right,
'>>>': (left: any, right: any) => left >>> right,
'^': (left: any, right: any) => left ^ right,
in: () => UnknownValue,
instanceof: () => UnknownValue,
'|': (left: any, right: any) => left | right
// We use the fallback for cases where we return something unknown
// in: () => UnknownValue,
// instanceof: () => UnknownValue,
};

export default class BinaryExpression extends NodeBase implements DeoptimizableEntity {
Expand Down
12 changes: 1 addition & 11 deletions src/ast/nodes/shared/MethodTypes.ts
@@ -1,13 +1,12 @@
import { type CallOptions, NO_ARGS } from '../../CallOptions';
import type { HasEffectsContext, InclusionContext } from '../../ExecutionContext';
import type { HasEffectsContext } from '../../ExecutionContext';
import { EVENT_CALLED, type NodeEvent } from '../../NodeEvents';
import { EMPTY_PATH, type ObjectPath, UNKNOWN_INTEGER_PATH } from '../../utils/PathTracker';
import {
UNKNOWN_LITERAL_BOOLEAN,
UNKNOWN_LITERAL_NUMBER,
UNKNOWN_LITERAL_STRING
} from '../../values';
import type SpreadElement from '../SpreadElement';
import { ExpressionEntity, UNKNOWN_EXPRESSION } from './Expression';

type MethodDescription = {
Expand Down Expand Up @@ -94,15 +93,6 @@ export class Method extends ExpressionEntity {
}
return false;
}

includeCallArguments(
context: InclusionContext,
args: readonly (ExpressionEntity | SpreadElement)[]
): void {
for (const arg of args) {
arg.include(context, false);
}
}
}

export const METHOD_RETURNS_BOOLEAN = [
Expand Down
3 changes: 3 additions & 0 deletions test/function/samples/parameter-side-effects/_config.js
@@ -0,0 +1,3 @@
module.exports = {
description: 'retains calls with parameter side effects'
};
12 changes: 12 additions & 0 deletions test/function/samples/parameter-side-effects/main.js
@@ -0,0 +1,12 @@
let effect = false;

function getPatternValueWithEffect() {
effect = true;
return 'value';
}

function test({ [getPatternValueWithEffect()]: value }) {}

test({ value: 'foo' });

assert.ok(effect);

0 comments on commit b5cd46e

Please sign in to comment.