error when using string to symbol hash key
See original GitHub issueMetadata
- Ruby version: ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-darwin17]
- @prettier/plugin-ruby version: 0.10.0
Input
{ 'a': 1 }
Current output
[error] a.rb: TypeError: Cannot read property 'type' of undefined
[error] at propagateBreaksOnEnterFn (prettier/bin-prettier.js:12581:13)
[error] at traverseDoc (prettier/bin-prettier.js:12439:11)
[error] at Object.propagateBreaks (prettier/bin-prettier.js:12606:3)
[error] at printAstToDoc (prettier/bin-prettier.js:13560:14)
[error] at coreFormat (prettier/bin-prettier.js:13871:16)
[error] at format (prettier/bin-prettier.js:14117:73)
[error] at formatWithCursor (prettier/bin-prettier.js:14133:12)
[error] at Object.formatWithCursor (prettier/bin-prettier.js:42401:15)
[error] at format$1 (prettier/bin-prettier.js:43770:21)
[error] at prettier/bin-prettier.js:43965:16
Expected output
{ a: 1 }
# or 'a': 1 as what's most likely is that I couldn't use a: 1 when the `a` in question, e.g. `$a`
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
ruby - Hash key access via symbol not string - Stack Overflow
This means that accessing table via :key is different from 'key' . Why? How do I convert table to make it work with...
Read more >How to access a Hash either string or symbol keys
These two examples show that you need to know the hash key's structure, whether it's a string or a symbol key, to access...
Read more >Intention "Convert string to symbol" doesn't appear ... - YouTrack
Intention "Convert string to symbol" doesn't appear for the string keys in hash. RM-119.20. Steps to reproduce: 1. Use this code(note that hashes...
Read more >Avoid silent failures & confusions in Ruby Hash
It's just confusing and easy to make mistakes about which type of keys (String vs Symbol) an existing hash is using if.
Read more >Hash - Rails API
Destructively converts all keys to symbols, as long as they respond to to_sym . This includes the keys from the root hash and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I just fixed it - got a PR coming very soon.
this is the
dyna_symbol
handler in v0.9.1looks like it’s trying to enforce the usage of a double-quote in that version, and in the latest version, it’s trying to maintain the quote choice that was used?
okay, digging a little deeper. There were some additions in https://github.com/prettier/plugin-ruby/commit/bf11b5e90753ca918baddee07a3c8020d8ef40d2#diff-db8f78209fc0a7d78756881ed982a3c3R245.
Here is the
path.getValue()
for the new test I added with the string symbol:Here is the
path.getValue()
for the existing string tests:in one case, it’s an
xstring
. Inside the hash, tho, it’s just astring