Project

General

Profile

Bug #13547

[].delete 1 { 'NG' }

Added by shyouhei (Shyouhei Urabe) 9 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0dev (2017-05-08 trunk 58609) [x86_64-darwin15]
[ruby-core:81037]

Description

Is this intentional?

% ruby --dump=parsetree -vwce "x 1 { 2 }"
ruby 2.5.0dev (2017-05-08 trunk 58609) [x86_64-darwin15]
Syntax OK
###########################################################
## Do NOT use this node dump for any purpose other than  ##
## debug and research.  Compatibility is not guaranteed. ##
###########################################################

# @ NODE_SCOPE (line: 1)
# +- nd_tbl: (empty)
# +- nd_args:
# |   (null node)
# +- nd_body:
#     @ NODE_PRELUDE (line: 1)
#     +- nd_head:
#     |   (null node)
#     +- nd_body:
#     |   @ NODE_ITER (line: 1)
#     |   +- nd_iter:
#     |   |   @ NODE_FCALL (line: 1)
#     |   |   +- nd_mid: :x
#     |   |   +- nd_args:
#     |   |       @ NODE_ARRAY (line: 1)
#     |   |       +- nd_alen: 1
#     |   |       +- nd_head:
#     |   |       |   @ NODE_LIT (line: 1)
#     |   |       |   +- nd_lit: 1
#     |   |       +- nd_next:
#     |   |           (null node)
#     |   +- nd_body:
#     |       @ NODE_SCOPE (line: 1)
#     |       +- nd_tbl: (empty)
#     |       +- nd_args:
#     |       |   (null node)
#     |       +- nd_body:
#     |           @ NODE_LIT (line: 1)
#     |           +- nd_lit: 2
#     +- nd_compile_option:
#         +- coverage_enabled: false

https://gist.github.com/JunichiIto/54f1d0dbb928566f5083b6caf9d8a2b2


Related issues

Related to Ruby trunk - Bug #505: 1.upto 2 {|i| p i }Closed2008-08-27
Related to Ruby trunk - Bug #11873: Syntax error and parse problem when calling a method without parenthesesClosed
Related to Ruby trunk - Bug #13691: Word- and symbol array literals not valid where regular array isOpen
Related to Ruby trunk - Bug #13898: Block parsing regressionRejected
Related to Ruby trunk - Bug #14023: SyntaxError on array argument and blockRejected

Associated revisions

Revision 58641
Added by nobu (Nobuyoshi Nakada) 9 months ago

parse.y: brace after literal arg

  • parse.y (symbol, dsym, parser_set_number_literal, parser_yylex): set state to END too not only ENDARG and after a literal, so that a left brace after it should be a primary block bound to the literal, which causes syntax error. [Bug #13547]

Revision 59409
Added by nagachika (Tomoyuki Chikanaga) 6 months ago

merge revision(s) 58641: [Backport #13547]

parse.y: brace after literal arg

* parse.y (symbol, dsym, parser_set_number_literal, parser_yylex):
  set state to END too not only ENDARG and after a literal, so
  that a left brace after it should be a primary block bound to
  the literal, which causes syntax error.
   [Bug #13547]

Revision 59420
Added by nobu (Nobuyoshi Nakada) 6 months ago

parse.y: brace after array literal arg

  • parse.y (parser_yylex): array is another literal. set state to END too not only ENDARG and after a literal, so that a left brace after it should be a primary block bound to the literal, which causes syntax error. [Bug #13547]

History

#1 Updated by shyouhei (Shyouhei Urabe) 9 months ago

  • Related to Bug #505: 1.upto 2 {|i| p i } added

#2 Updated by nobu (Nobuyoshi Nakada) 9 months ago

  • Related to Bug #11873: Syntax error and parse problem when calling a method without parentheses added

#3 Updated by nobu (Nobuyoshi Nakada) 9 months ago

  • Status changed from Open to Closed

Applied in changeset trunk|r58641.


parse.y: brace after literal arg

  • parse.y (symbol, dsym, parser_set_number_literal, parser_yylex): set state to END too not only ENDARG and after a literal, so that a left brace after it should be a primary block bound to the literal, which causes syntax error. [Bug #13547]

#4 [ruby-core:82139] Updated by nagachika (Tomoyuki Chikanaga) 6 months ago

  • Backport changed from 2.2: DONTNEED, 2.3: DONTNEED, 2.4: REQUIRED to 2.2: DONTNEED, 2.3: DONTNEED, 2.4: DONE

ruby_2_4 r59409 merged revision(s) 58641.

#5 Updated by nobu (Nobuyoshi Nakada) 6 months ago

  • Related to Bug #13691: Word- and symbol array literals not valid where regular array is added

#6 Updated by nobu (Nobuyoshi Nakada) 4 months ago

  • Related to Bug #13898: Block parsing regression added

#7 Updated by wanabe (_ wanabe) 3 months ago

  • Related to Bug #14023: SyntaxError on array argument and block added

Also available in: Atom PDF