diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2018-07-28 00:07:56 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-05-05 00:29:12 +0900 |
commit | ff21e75d32e27a2b362ed53fb471828876b54418 (patch) | |
tree | f32f96d4bfb0ecf917428a893d9aff9bb84a47cc /compile.c | |
parent | 848edb03f8d3e5f5e97d3ea45fec592d87d73b05 (diff) | |
download | ruby-ff21e75d32e27a2b362ed53fb471828876b54418.tar.gz |
parse.y: duplicated when clause warning
* parse.y (case_args): moved "duplicated when clause" warning from
compile phase, so that `ruby -wc` shows them.
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 17 |
1 files changed, 5 insertions, 12 deletions
@@ -4073,8 +4073,8 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node_ro return len; } -static VALUE -case_when_optimizable_literal(const NODE *const node) +VALUE +rb_node_case_when_optimizable_literal(const NODE *const node) { switch (nd_type(node)) { case NODE_LIT: { @@ -4107,20 +4107,13 @@ when_vals(rb_iseq_t *iseq, LINK_ANCHOR *const cond_seq, const NODE *vals, { while (vals) { const NODE *val = vals->nd_head; - VALUE lit = case_when_optimizable_literal(val); + VALUE lit = rb_node_case_when_optimizable_literal(val); if (lit == Qundef) { only_special_literals = 0; } - else { - if (rb_hash_lookup(literals, lit) != Qnil) { - VALUE file = rb_iseq_path(iseq); - rb_compile_warning(RSTRING_PTR(file), nd_line(val), - "duplicated when clause is ignored"); - } - else { - rb_hash_aset(literals, lit, (VALUE)(l1) | 1); - } + else if (NIL_P(rb_hash_lookup(literals, lit))) { + rb_hash_aset(literals, lit, (VALUE)(l1) | 1); } ADD_INSN(cond_seq, nd_line(val), dup); /* dup target */ |