Drop token info also for endless singleton method definition
This commit is contained in:
parent
ffc8a72f39
commit
8e03e3b0ba
15
parse.y
15
parse.y
@ -401,6 +401,12 @@ static int parser_yyerror(struct parser_params*, const YYLTYPE *yylloc, const ch
|
||||
#define yyerror(yylloc, p, msg) parser_yyerror(p, yylloc, msg)
|
||||
#define token_flush(ptr) ((ptr)->lex.ptok = (ptr)->lex.pcur)
|
||||
|
||||
static void token_info_setup(token_info *ptinfo, const char *ptr, const rb_code_location_t *loc);
|
||||
static void token_info_push(struct parser_params*, const char *token, const rb_code_location_t *loc);
|
||||
static void token_info_pop(struct parser_params*, const char *token, const rb_code_location_t *loc);
|
||||
static void token_info_warn(struct parser_params *p, const char *token, token_info *ptinfo_beg, int same, const rb_code_location_t *loc);
|
||||
static void token_info_drop(struct parser_params *p, const char *token, rb_code_position_t beg_pos);
|
||||
|
||||
#ifdef RIPPER
|
||||
#define compile_for_eval (0)
|
||||
#else
|
||||
@ -986,6 +992,7 @@ endless_method_name(struct parser_params *p, NODE *defn, const YYLTYPE *loc)
|
||||
if (is_attrset_id(mid)) {
|
||||
yyerror1(loc, "setter method cannot be defined in an endless method definition");
|
||||
}
|
||||
token_info_drop(p, "def", loc->beg_pos);
|
||||
}
|
||||
|
||||
#ifndef RIPPER
|
||||
@ -1060,12 +1067,6 @@ PRINTF_ARGS(static void parser_compile_error(struct parser_params*, const char *
|
||||
# define compile_error parser_compile_error
|
||||
#endif
|
||||
|
||||
static void token_info_setup(token_info *ptinfo, const char *ptr, const rb_code_location_t *loc);
|
||||
static void token_info_push(struct parser_params*, const char *token, const rb_code_location_t *loc);
|
||||
static void token_info_pop(struct parser_params*, const char *token, const rb_code_location_t *loc);
|
||||
static void token_info_warn(struct parser_params *p, const char *token, token_info *ptinfo_beg, int same, const rb_code_location_t *loc);
|
||||
static void token_info_drop(struct parser_params *p, const char *token, rb_code_position_t beg_pos);
|
||||
|
||||
#define WARN_EOL(tok) \
|
||||
(looking_at_eol_p(p) ? \
|
||||
(void)rb_warning0("`" tok "' at the end of line without an expression") : \
|
||||
@ -2499,7 +2500,6 @@ arg : lhs '=' lex_ctxt arg_rhs
|
||||
| defn_head f_opt_paren_args '=' arg
|
||||
{
|
||||
endless_method_name(p, $<node>1, &@1);
|
||||
token_info_drop(p, "def", @1.beg_pos);
|
||||
restore_defun(p, $<node>1->nd_defn);
|
||||
/*%%%*/
|
||||
$$ = set_defun_body(p, $1, $2, $4, &@$);
|
||||
@ -2510,7 +2510,6 @@ arg : lhs '=' lex_ctxt arg_rhs
|
||||
| defn_head f_opt_paren_args '=' arg modifier_rescue arg
|
||||
{
|
||||
endless_method_name(p, $<node>1, &@1);
|
||||
token_info_drop(p, "def", @1.beg_pos);
|
||||
restore_defun(p, $<node>1->nd_defn);
|
||||
/*%%%*/
|
||||
$4 = rescued_expr(p, $4, $6, &@4, &@5, &@6);
|
||||
|
@ -504,6 +504,7 @@ class TestRubyOptions < Test::Unit::TestCase
|
||||
["if false;", "end", "if true\nelse ", "end"],
|
||||
["else", " end", "_ = if true\n"],
|
||||
["begin\n def f() = nil", "end"],
|
||||
["begin\n def self.f() = nil", "end"],
|
||||
].each do
|
||||
|b, e = 'end', pre = nil, post = nil|
|
||||
src = ["#{pre}#{b}\n", " #{e}\n#{post}"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user