Better dead code elimination
See original GitHub issueno-unreachable fails to detect some of the cases of unreachable code. For example,
(function() {
var foo = null;
if (!foo) {
return;
}
(function dead(){})();
})();
should warn about dead
function (since it’s statically determinable).
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:15 (12 by maintainers)
Top Results From Across the Web
Dead-code elimination - Wikipedia
In compiler theory, dead-code elimination is a compiler optimization to remove code which does not affect the program results. Removing such code has ......
Read more >Dead Code Elimination
Removing such code has several benefits: it shrinks program size and it allows the running program to avoid executing irrelevant operations, which reduces...
Read more >How to Find and Remove Dead Code - LinearB
This optimization technique is called dead code elimination. Since the mid-2010s, similar technology has been used in IDEs to highlight lines ...
Read more >Better dead code elimination for swc minify. #3629 - GitHub
It's problem of top-level . swc emits identical output if you set toplevel: true. All reactions.
Read more >Chapter 4. Improve Code by Removing It - O'Reilly
There is no harm in removing dead code. Amputate it. It's not like you're throwing it away. Whenever you realise that you need...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If we were to add something like this to ESLint, I would seriously consider adding it to Escope instead. Escope already checked all of the declarations in the AST, so enhancing it to track type inference would be simpler then adding something like that to ESLint core itself.
We’re working on some Babel tooling that uses it’s APIs. Babel scope tracking tracks constant values and knows that
foo
will always benull
. Then some of our evaluation helpers determine thatif (!foo)
will always betrue
. There’s no Flow type information required.