Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ruby/prism] String literal hash keys should be frozen
String literal hash keys can't be mutated by the user so we should mark them as frozen. We were seeing instructions for hashes with string literal keys using two `putstring` instructions when it should be a `putobject` and `putstring`. Code example: ```ruby { "a" => "b" } ``` Instructions before: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(2,14)> 0000 putobject "a" ( 2)[Li] 0002 putstring "b" 0004 newhash 2 0006 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,14)> 0000 putstring "a" ( 1)[Li] 0002 putstring "b" 0004 newhash 2 0006 leave ``` Instructions after: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(2,14)> 0000 putobject "a" ( 2)[Li] 0002 putstring "b" 0004 newhash 2 0006 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,14)> 0000 putobject "a" ( 1)[Li] 0002 putstring "b" 0004 newhash 2 0006 leave ``` ruby/prism@b14ae55385
- Loading branch information