FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Hash as literal Array is marked as kwargs · Issue #9370 · jruby/jruby · GitHub

/ jruby Public

Hash as literal Array is marked as kwargs #9370

Description

When an Array literal is used to construct an array containing a hash (a baffling feature I did not know existed), it is marked as a kwargs hash. When a literal Hash is constructed the same way, it is not.

I believe the latter is incorrect, because non-symbol keys end up getting passed through as a kwargs HashNode, but kwargs should never have any non-symbol keys.

$ ast -e '["foo" => 1, a: 2] == [{"foo" => 1, a: 2}]'   
AST:
RootNode line: 0
  OperatorCallNode*:== line: 0
    ArrayNode line: 0
      HashNode line: 0, kwarg
        StrNode line: 0
        FixnumNode line: 0, long: 1
        SymbolNode:a line: 0
        FixnumNode line: 0, long: 2
    ArrayNode line: 0
      ArrayNode line: 0
        HashNode line: 0, literal
          StrNode line: 0
          FixnumNode line: 0, long: 1
          SymbolNode:a line: 0
          FixnumNode line: 0, long: 2
, null

This came up while trying to finalize #9219. There may be other cases that are also being incorrectly marked as kwargs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL