diff options
author | Jeremy Evans <[email protected]> | 2020-02-11 11:56:34 -0800 |
---|---|---|
committer | Jeremy Evans <[email protected]> | 2020-02-11 12:44:23 -0800 |
commit | 7a288df7b85d3565f369b305f225c2cd5baa5905 (patch) | |
tree | 994eea5130e4d2e78773b4ee383b63ff46d43740 /compile.c | |
parent | ea32715e004dc8f56dc599883d3183d7b2635f81 (diff) |
Make yield in singleton class definitions in methods a SyntaxError
This behavior was deprecated in 2.7 and scheduled to be removed
in 3.0.
Calling yield in a class definition outside a method is now a
SyntaxError instead of a LocalJumpError, as well.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2901
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 13 |
1 files changed, 3 insertions, 10 deletions
@@ -7096,20 +7096,13 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, const NODE *node, int poppe } static int -check_yield_place(const rb_iseq_t *iseq, int line) +check_yield_place(const rb_iseq_t *iseq) { - VALUE file; switch (iseq->body->local_iseq->body->type) { case ISEQ_TYPE_TOP: case ISEQ_TYPE_MAIN: - return FALSE; case ISEQ_TYPE_CLASS: - file = rb_iseq_path(iseq); - if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_DEPRECATED)) { - rb_compile_warn(RSTRING_PTR(file), line, - "`yield' in class syntax will not be supported from Ruby 3.0. [Feature #15575]"); - } - return TRUE; + return FALSE; default: return TRUE; } @@ -7836,7 +7829,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in INIT_ANCHOR(args); - if (check_yield_place(iseq, line) == FALSE) { + if (check_yield_place(iseq) == FALSE) { COMPILE_ERROR(ERROR_ARGS "Invalid yield"); goto ng; } |