Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct the pattern for checking if a dynamic symbol can be converted into a label as a hash key. #77

Merged
merged 1 commit into from
May 13, 2022
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a

## [Unreleased]

### Changed

- Correct the pattern for checking if a dynamic symbol can be converted into a label as a hash key.

## [2.4.1] - 2022-05-10

- [#73](https://github.com/ruby-syntax-tree/syntax_tree/pull/73) - Fix nested hash patterns from accidentally adding a `then` to their output.
Expand Down
2 changes: 1 addition & 1 deletion lib/syntax_tree/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ def format(q)
module HashKeyFormatter
# Formats the keys of a hash literal using labels.
class Labels
LABEL = /^[@$_A-Za-z]([_A-Za-z0-9]*)?([!_=?A-Za-z0-9])?$/
LABEL = /\A[A-Za-z_](\w*[\w!?])?\z/

def format_key(q, key)
case key
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/assoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@
{ foo: "bar" }
%
{ "foo #{bar}": "baz" }
%
{ "foo=": "baz" }