diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-07-30 16:15:19 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2020-01-03 20:13:09 -0800 |
commit | 0eeed5bcc5530edb0af2af2ccff09d067c59e8f9 (patch) | |
tree | 7a3aceb0e9ddc67ab4ca1dfe4534eb1515aa49c6 /parse.y | |
parent | 170f4dbb9bf9363c9fd012fc3f4e340ccda43273 (diff) |
Make eval(code, binding) use (eval) as __FILE__ and 1 as __LINE__
This removes the warning that was added in
3802fb92ff8c83eed3e867db20f72c53932f542d, and switches the behavior
so that the eval does not use the binding's __FILE__ and __LINE__
implicitly.
Fixes [Bug #4352]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2816
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 24 |
1 files changed, 0 insertions, 24 deletions
@@ -315,7 +315,6 @@ struct parser_params { unsigned int do_loop: 1; unsigned int do_chomp: 1; unsigned int do_split: 1; - unsigned int warn_location: 1; NODE *eval_tree_begin; NODE *eval_tree; @@ -9917,19 +9916,6 @@ 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) { \ - 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) - static int numparam_nested_p(struct parser_params *p) { @@ -9963,7 +9949,6 @@ gettable(struct parser_params *p, ID id, const YYLTYPE *loc) case keyword_false: return NEW_FALSE(loc); case keyword__FILE__: - WARN_LOCATION("__FILE__"); { VALUE file = p->ruby_sourcefile_string; if (NIL_P(file)) @@ -9975,7 +9960,6 @@ gettable(struct parser_params *p, ID id, const YYLTYPE *loc) } return node; case keyword__LINE__: - WARN_LOCATION("__LINE__"); return NEW_LIT(INT2FIX(p->tokline), loc); case keyword__ENCODING__: node = NEW_LIT(rb_enc_from_encoding(p->enc), loc); @@ -12248,14 +12232,6 @@ rb_parser_set_options(VALUE vparser, int print, int loop, int chomp, int split) p->do_split = split; } -void -rb_parser_warn_location(VALUE vparser, int warn) -{ - struct parser_params *p; - TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p); - p->warn_location = warn; -} - static NODE * parser_append_options(struct parser_params *p, NODE *node) { |