Skip to content

Commit 804a1b6

Browse files
committed
feature: @putout/processor-wasm: rules: remove-unused: exclude called
1 parent a68b365 commit 804a1b6

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(module
2+
(func $one (result i32)
3+
i32.const 1
4+
)
5+
6+
(func $oneTwo (result i32 i32)
7+
(call $one)
8+
i32.const 2
9+
)
10+
11+
(export "theAnswer" (func $oneTwo))
12+
)

packages/processor-wasm/lib/rules/remove-unused/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export const find = (ast, {push, traverse}) => {
1818
const {value} = path.node.descr.id;
1919
delete funcs[value];
2020
},
21+
CallInstruction(path) {
22+
const {value} = path.node.index;
23+
delete funcs[value];
24+
},
2125
});
2226

2327
for (const [, path] of entries(funcs)) {

packages/processor-wasm/lib/rules/remove-unused/index.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ test('putout: processor-wasm: remove-unused: no report: exported', (t) => {
2121
t.noReport('exported');
2222
t.end();
2323
});
24+
25+
test('putout: processor-wasm: remove-unused: no report: called', (t) => {
26+
t.noReport('called');
27+
t.end();
28+
});

0 commit comments

Comments
 (0)