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

ruby-changes:56778

From: Nobuyoshi <ko1@a...>
Date: Sat, 3 Aug 2019 11:32:56 +0900 (JST)
Subject: [ruby-changes:56778] Nobuyoshi Nakada: 688a59f8ac (master): Show the location of `eval` which uses `__FILE__`/`__LINE__`

https://git.ruby-lang.org/ruby.git/commit/?id=688a59f8ac

From 688a59f8ac984a2f1d4d53005dbe0679dcd59ac3 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sat, 3 Aug 2019 11:31:40 +0900
Subject: Show the location of `eval` which uses `__FILE__`/`__LINE__`


diff --git a/parse.y b/parse.y
index 447c7d3..3bff42a 100644
--- a/parse.y
+++ b/parse.y
@@ -9739,10 +9739,16 @@ past_dvar_p(struct parser_params *p, ID id) https://github.com/ruby/ruby/blob/trunk/parse.y#L9739
 }
 # endif
 
+/* As Ripper#warn does not have arguments for the location, so the
+ * following messages cannot be separated */
 #define WARN_LOCATION(type) do { \
     if (p->warn_location) { \
-	rb_warn0(type" in eval may not return location in binding;" \
-		    " use Binding#source_location instead"); \
+	int line; \
+	VALUE file = rb_source_location(&line); \
+	rb_warn3(type" in eval may not return location in binding;" \
+		 " use Binding#source_location instead\n" \
+		 "%"PRIsWARN":%d: warning: in `%"PRIsWARN"'", \
+		 file, WARN_I(line), rb_id2str(rb_frame_this_func())); \
     } \
 } while (0)
 
-- 
cgit v0.10.2


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

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