aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
diff options
context:
space:
mode:
authoryui-knk <spiketeika@gmail.com>2023-10-20 21:30:18 +0900
committerYuichiro Kaneko <spiketeika@gmail.com>2023-10-31 17:49:12 +0900
commit51149f335e4aea3465bd52a98f85351455bf320e (patch)
treeb3eaf51570be281b7acbf0b2df6a5b058c91dfd1 /parse.y
parenteff59e93df1102d990a61965d906a28d55abc14a (diff)
downloadruby-51149f335e4aea3465bd52a98f85351455bf320e.tar.gz
Keep unused literal nodes
For static analysis, it’s better to keep unused literal nodes. If simply change `block_append` to fall through, both "unused literal ignored" and "possibly useless use of a literal in void context" warnings are shown for the same line. But it’s verbose then remove "unused literal ignored" warning. This kind of optimization is already implemented on compile.c. `compile_block` calls `iseq_compile_each0` with `popped = 1` when NODE_BLOCK has next.
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y8
1 files changed, 0 insertions, 8 deletions
diff --git a/parse.y b/parse.y
index 1eaaf9442f..caddbcc178 100644
--- a/parse.y
+++ b/parse.y
@@ -12291,14 +12291,6 @@ block_append(struct parser_params *p, NODE *head, NODE *tail)
if (h == 0) return tail;
switch (nd_type(h)) {
- case NODE_LIT:
- case NODE_STR:
- case NODE_SELF:
- case NODE_TRUE:
- case NODE_FALSE:
- case NODE_NIL:
- parser_warning(p, h, "unused literal ignored");
- return tail;
default:
h = end = NEW_BLOCK(head, &head->nd_loc);
RNODE_BLOCK(end)->nd_end = end;