Skip to content
Merged
Show file tree
Hide file tree
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
62 changes: 62 additions & 0 deletions snapshots/pattern_one_line_bare_key.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@ ProgramNode (location: (1,0)-(1,15))
├── flags: ∅
├── locals: [:b]
└── statements:
@ StatementsNode (location: (1,0)-(1,15))
├── flags: ∅
└── body: (length: 1)
└── @ MatchRequiredNode (location: (1,0)-(1,15))
├── flags: newline
├── value:
│ @ CallNode (location: (1,0)-(1,3))
│ ├── flags: variable_call, ignore_visibility
│ ├── receiver: ∅
│ ├── call_operator_loc: ∅
│ ├── name: :foo
│ ├── message_loc: (1,0)-(1,3) = "foo"
│ ├── opening_loc: ∅
│ ├── arguments: ∅
│ ├── closing_loc: ∅
│ ├── equal_loc: ∅
│ └── block: ∅
├── pattern:
│ @ HashPatternNode (location: (1,7)-(1,15))
│ ├── flags: ∅
│ ├── constant: ∅
│ ├── elements: (length: 2)
│ │ ├── @ AssocNode (location: (1,7)-(1,11))
│ │ │ ├── flags: static_literal
│ │ │ ├── key:
│ │ │ │ @ SymbolNode (location: (1,7)-(1,9))
│ │ │ │ ├── flags: static_literal, forced_us_ascii_encoding
│ │ │ │ ├── opening_loc: ∅
│ │ │ │ ├── value_loc: (1,7)-(1,8) = "a"
│ │ │ │ ├── closing_loc: (1,8)-(1,9) = ":"
│ │ │ │ └── unescaped: "a"
│ │ │ ├── value:
│ │ │ │ @ IntegerNode (location: (1,10)-(1,11))
│ │ │ │ ├── flags: static_literal, decimal
│ │ │ │ └── value: 1
│ │ │ └── operator_loc: ∅
│ │ └── @ AssocNode (location: (1,13)-(1,15))
│ │ ├── flags: ∅
│ │ ├── key:
│ │ │ @ SymbolNode (location: (1,13)-(1,15))
│ │ │ ├── flags: static_literal, forced_us_ascii_encoding
│ │ │ ├── opening_loc: ∅
│ │ │ ├── value_loc: (1,13)-(1,14) = "b"
│ │ │ ├── closing_loc: (1,14)-(1,15) = ":"
│ │ │ └── unescaped: "b"
│ │ ├── value:
│ │ │ @ ImplicitNode (location: (1,13)-(1,14))
│ │ │ ├── flags: ∅
│ │ │ └── value:
│ │ │ @ LocalVariableTargetNode (location: (1,13)-(1,14))
│ │ │ ├── flags: ∅
│ │ │ ├── name: :b
│ │ │ └── depth: 0
│ │ └── operator_loc: ∅
│ ├── rest: ∅
│ ├── opening_loc: ∅
│ └── closing_loc: ∅
└── operator_loc: (1,4)-(1,6) = "=>"
2 changes: 1 addition & 1 deletion src/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -16907,7 +16907,7 @@ parse_pattern_hash(pm_parser_t *parser, pm_constant_id_list_t *captures, pm_node
parse_pattern_hash_key(parser, &keys, key);
pm_node_t *value = NULL;

if (match7(parser, PM_TOKEN_COMMA, PM_TOKEN_KEYWORD_THEN, PM_TOKEN_BRACE_RIGHT, PM_TOKEN_BRACKET_RIGHT, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON)) {
if (match8(parser, PM_TOKEN_COMMA, PM_TOKEN_KEYWORD_THEN, PM_TOKEN_BRACE_RIGHT, PM_TOKEN_BRACKET_RIGHT, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON, PM_TOKEN_EOF)) {
if (PM_NODE_TYPE_P(key, PM_SYMBOL_NODE)) {
value = parse_pattern_hash_implicit_value(parser, captures, (pm_symbol_node_t *) key);
} else {
Expand Down
1 change: 0 additions & 1 deletion test/prism/errors/pattern_string_key.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ case:a
^~~~ expected an `end` to close the `case` statement
in b:"","#{}"
^~~~~ expected a label after the `,` in the hash pattern
^ expected a pattern expression after the key
^ expected a delimiter after the patterns of an `in` clause
^ unexpected end-of-input, assuming it is closing the parent top level context

1 change: 1 addition & 0 deletions test/prism/fixtures/pattern_one_line_bare_key.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo => a: 1, b: