diff --git a/ChangeLog b/ChangeLog index 4654a93e11..2c554d4ef4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Mar 16 17:42:05 2012 Nobuyoshi Nakada + + * parse.y (block_append_gen): fix unreachable warning line number. + should warn at the code, not jump. + Fri Mar 16 17:33:08 2012 Nobuyoshi Nakada * enum.c (enum_take): allocate buffer array before iteration, as well diff --git a/parse.y b/parse.y index ff7fb51899..0393dc1421 100644 --- a/parse.y +++ b/parse.y @@ -8155,7 +8155,7 @@ block_append_gen(struct parser_params *parser, NODE *head, NODE *tail) case NODE_REDO: case NODE_RETRY: if (RTEST(ruby_verbose)) { - parser_warning(nd, "statement not reached"); + parser_warning(tail, "statement not reached"); } break; diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 8be81dcb4d..51a0f355f8 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -96,6 +96,13 @@ class TestSyntax < Test::Unit::TestCase end end + def test_warn_unreachable + assert_warn("test:3: warning: statement not reached\n") do + code = "loop do\n" "break\n" "foo\n" "end" + assert_valid_syntax(code, "test") {$VERBOSE = true} + end + end + private def make_tmpsrc(f, src)