summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2018-07-28 00:07:56 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-05-05 00:29:12 +0900
commitff21e75d32e27a2b362ed53fb471828876b54418 (patch)
treef32f96d4bfb0ecf917428a893d9aff9bb84a47cc /compile.c
parent848edb03f8d3e5f5e97d3ea45fec592d87d73b05 (diff)
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.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/compile.c b/compile.c
index ca117c2853..7dbf244f36 100644
--- a/compile.c
+++ b/compile.c
@@ -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 */