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

Deconflict unused parameters #2972

Merged
merged 1 commit into from Jun 29, 2019
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
2 changes: 1 addition & 1 deletion src/ast/scopes/ChildScope.ts
Expand Up @@ -67,7 +67,7 @@ export default class ChildScope extends Scope {
}
}
for (const [name, variable] of this.variables) {
if (variable.included) {
if (variable.included || variable.alwaysRendered) {
variable.setSafeName(getSafeName(name, usedNames));
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/ast/scopes/ParameterScope.ts
Expand Up @@ -38,6 +38,11 @@ export default class ParameterScope extends ChildScope {

addParameterVariables(parameters: LocalVariable[][], hasRest: boolean) {
this.parameters = parameters;
for (const parameterList of parameters) {
for (const parameter of parameterList) {
parameter.alwaysRendered = true;
}
}
this.hasRest = hasRest;
}

Expand Down
1 change: 1 addition & 0 deletions src/ast/variables/Variable.ts
Expand Up @@ -11,6 +11,7 @@ import { ImmutableEntityPathTracker } from '../utils/ImmutableEntityPathTracker'
import { LiteralValueOrUnknown, ObjectPath, UNKNOWN_EXPRESSION, UNKNOWN_VALUE } from '../values';

export default class Variable implements ExpressionEntity {
alwaysRendered = false;
exportName: string | null = null;
included = false;
isId = false;
Expand Down
@@ -0,0 +1,4 @@
module.exports = {
solo: true,
description: 'does not cause conflicts when deconflicting non-included parameters'
};
@@ -0,0 +1,2 @@
export let value = 0;
export const mutate = () => value++;
@@ -0,0 +1,9 @@
import * as dep from './dep';

function test(mutate) {
dep.mutate('hello');
}

test();

assert.strictEqual(dep.value, 1);