Skip to content

Commit 41f4ac6

Browse files
committed
ast.c: use enum in switch for warnings
* ext/-test-/ast/ast.c (node_children): use enum instead of int for not-handled enumeration value in switch warnings. * ext/-test-/ast/ast.c (node_children): fix the rb_bug message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 496ddbc commit 41f4ac6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/-test-/ast/ast.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ dump_array(rb_ast_t *ast, NODE *node)
179179
static VALUE
180180
node_children(rb_ast_t *ast, NODE *node)
181181
{
182-
switch (nd_type(node)) {
182+
enum node_type type = nd_type(node);
183+
switch (type) {
183184
case NODE_BLOCK:
184185
return dump_block(ast, node);
185186
case NODE_IF:
@@ -227,7 +228,6 @@ node_children(rb_ast_t *ast, NODE *node)
227228
andor:
228229
{
229230
VALUE ary = rb_ary_new();
230-
enum node_type type = nd_type(node);
231231

232232
while (1) {
233233
rb_ary_push(ary, NEW_CHILD(ast, node->nd_1st));
@@ -417,7 +417,7 @@ node_children(rb_ast_t *ast, NODE *node)
417417
break;
418418
}
419419

420-
rb_bug("dump_node: unknown node: %s", ruby_node_name(nd_type(node)));
420+
rb_bug("node_children: unknown node: %s", ruby_node_name(type));
421421
}
422422

423423
static VALUE

0 commit comments

Comments
 (0)