[前][次][番号順一覧][スレッド一覧]

ruby-changes:54782

From: nobu <ko1@a...>
Date: Mon, 4 Feb 2019 17:13:41 +0900 (JST)
Subject: [ruby-changes:54782] nobu:r67001 (trunk): Show proper location for warning [Feature #15575]

nobu	2019-02-04 17:13:37 +0900 (Mon, 04 Feb 2019)

  New Revision: 67001

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67001

  Log:
    Show proper location for warning [Feature #15575]

  Modified files:
    trunk/compile.c
Index: compile.c
===================================================================
--- compile.c	(revision 67000)
+++ compile.c	(revision 67001)
@@ -5922,14 +5922,17 @@ qcall_branch_end(rb_iseq_t *iseq, LINK_A https://github.com/ruby/ruby/blob/trunk/compile.c#L5922
 }
 
 static int
-check_yield_place(const rb_iseq_t *iseq)
+check_yield_place(const rb_iseq_t *iseq, int line)
 {
+    VALUE file;
     switch (iseq->body->local_iseq->body->type) {
       case ISEQ_TYPE_TOP:
       case ISEQ_TYPE_MAIN:
         return FALSE;
       case ISEQ_TYPE_CLASS:
-        rb_warn("`yield' in class syntax will not be supported from Ruby 3.0. [Feature #15575]");
+        file = rb_iseq_path(iseq);
+        rb_compile_warn(RSTRING_PTR(file), line,
+                        "`yield' in class syntax will not be supported from Ruby 3.0. [Feature #15575]");
         return TRUE;
       default:
         return TRUE;
@@ -6843,7 +6846,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L6846
 
 	INIT_ANCHOR(args);
 
-        if (check_yield_place(iseq) == FALSE) {
+        if (check_yield_place(iseq, line) == FALSE) {
 	    COMPILE_ERROR(ERROR_ARGS "Invalid yield");
             goto ng;
         }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]