psych icon indicating copy to clipboard operation
psych copied to clipboard

Strange `FrozenError` on `Psych.load`

Open shyouhei opened this issue 2 years ago • 1 comments

Is it intentional for the following Ruby code to raise FrozenError ?

Psych.safe_load(<<~'end', aliases: true, freeze: true)
  ---
  foo: &foo
    <<: *foo
end

Possibilities:

  • Psych should accept this YAML and properly return a frozen, recursive hash.
  • Psych should raise Psych::AnchorNotDefined instead of FrozenError.
  • FrozenError is the legit exception here.

I have no idea if the YAML in question is valid or not at the first place.

shyouhei avatar Nov 22 '23 02:11 shyouhei

  • Psych should accept this YAML and properly return a frozen, recursive hash.

IMO this is the correct behavior. I'm not sure how hard it is to implement though.

tenderlove avatar Jan 18 '24 17:01 tenderlove