Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

1. Calling a method with ++ (Integer#succ) #1

Open
wants to merge 1 commit into
base: ruby_3_2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ parser_token2id(enum yytokentype tok)
TOKEN2ID(tCOLON2);
TOKEN2ID(tCOLON3);
TOKEN2ID(tOP_ASGN);
TOKEN2ID(tINCOP);
TOKEN2ID(tASSOC);
TOKEN2ID(tLPAREN);
TOKEN2ID(tLPAREN_ARG);
Expand Down Expand Up @@ -1519,6 +1520,7 @@ static int looking_at_eol_p(struct parser_params *p);
%token <id> tANDDOT RUBY_TOKEN(ANDDOT) "&."
%token <id> tCOLON2 RUBY_TOKEN(COLON2) "::"
%token tCOLON3 ":: at EXPR_BEG"
%token <id> tINCOP "increment-operator" /* ++ */
%token <id> tOP_ASGN "operator-assignment" /* +=, -= etc. */
%token tASSOC "=>"
%token tLPAREN "("
Expand Down Expand Up @@ -1557,7 +1559,7 @@ static int looking_at_eol_p(struct parser_params *p);
%left keyword_or keyword_and
%right keyword_not
%nonassoc keyword_defined
%right '=' tOP_ASGN
%right '=' tOP_ASGN tINCOP
%left modifier_rescue
%right '?' ':'
%nonassoc tDOT2 tDOT3 tBDOT2 tBDOT3
Expand Down Expand Up @@ -4291,6 +4293,15 @@ method_call : fcall paren_args
/*% %*/
/*% ripper: aref!($1, escape_Qundef($3)) %*/
}
| primary_value lex_ctxt tINCOP
{
/*%%%*/
SET_LEX_STATE(EXPR_END);
ID succ = rb_intern("succ");
$$ = new_qcall(p, $3, $1, succ, Qnull, &@3, &@$);
nd_set_line($$, @3.end_pos.lineno);
/*% %*/
}
;

brace_block : '{' brace_body '}'
Expand Down Expand Up @@ -10178,6 +10189,9 @@ parser_yylex(struct parser_params *p)
}
return tUPLUS;
}
if (c == '+') {
return tINCOP;
}
SET_LEX_STATE(EXPR_BEG);
pushback(p, c);
return warn_balanced('+', "+", "unary operator");
Expand Down
Loading