summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-08-03 11:31:40 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-08-03 11:32:37 +0900
commit688a59f8ac984a2f1d4d53005dbe0679dcd59ac3 (patch)
treed37a72bb17772c9c0f46781a955238864934f957 /parse.y
parentfb96bea7ed8ed6765fda2a1db90a2cfce14e59b7 (diff)
Show the location of `eval` which uses `__FILE__`/`__LINE__`
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y10
1 files changed, 8 insertions, 2 deletions
diff --git a/parse.y b/parse.y
index 447c7d3463..3bff42ac56 100644
--- a/parse.y
+++ b/parse.y
@@ -9739,10 +9739,16 @@ past_dvar_p(struct parser_params *p, ID id)
}
# 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)