Issue #14506 has been updated by nobu (Nobuyoshi Nakada).

Tracker changed from Bug to Feature
ruby -v deleted (ruby 2.6.0dev (2018-02-19 trunk 62484) [x86_64-darwin17])
Backport deleted (2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN)

ibylich (Ilya Bylich) wrote:
> > Maybe, `lambda` and `brace_body` parts aren't needed?
> 
> Maybe, I didn't have a chance to test it. Would you like me to check and revert this part?

No, just confirmed.

> No, when lexer comes to the "do" token it has a state "EXPR_END|EXPR_ENDARG". I understand that it's a bitmask, but from what I see "EXPR_ENDARG" flag is needed only for emitting "do" as "keyword_do_block" (while originally cmdarg is designed to handle it and moreover, it can handle it on its own). Ragel doesn't support such states, in the parser gem it can be either EXPR_END or EXPR_ENDARG, but not both at the same time. That's why I have troubles with backporting it.

Thank you for clarification.


----------------------------------------
Feature #14506: Possible bug in cmdarg_stack
https://bugs.ruby-lang.org/issues/14506#change-70592

* Author: ibylich (Ilya Bylich)
* Status: Assigned
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 
----------------------------------------
cmdarg stack is a stack of bytes that has 1 on top of it when the parser is in the command mode.

But for this code:

~~~ ruby
a b(c d), "x" do end
~~~

And this line in parse.y:

~~~ c
> SHOW_BITSTACK(p->cmdarg_stack, "BEFORE kDO_BLOCK");
if (CMDARG_P() && !IS_lex_state_for(state, EXPR_CMDARG))
  return keyword_do_block;
~~~

It prints:

~~~ text
$ dev-ruby -vye 'a b(c d), "x" do end' | grep -E "kDO_BLOCK"
BEFORE kDO_BLOCK: 10 at line 7461
~~~

So CMDARG_P is false. I understand that 'keyword_do_block" is handled later in the "if (IS_lex_state_for(state, (EXPR_BEG | EXPR_ENDARG)))" section, but is it possible to change parser to rely only on cmdarg stack?



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>