ruby / ruby/psych

`ruby/object:*` tag not used for scalar value

Open
#398 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
597
Forks
223
Avg merge
11h 23m
Merged PRs (30d)
3

Description

class Custom
    def initialize
      @value = 1
    end

    def encode_with(coder)
      coder.scalar = @value.to_s
    end

    def init_with(coder)
      @value = coder.scalar.to_i
    end
end

YAML::load(YAML::dump(Custom.new)) # => 1

Would expect that to return a Custom since dump emits the correct tag, bug instead get 1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the Ruby reproduction using Custom#encode_with, Custom#init_with, YAML::dump, and YAML::load. Trace how Psych handles the emitted ruby/object:* tag when the serialized value is scalar. Done means loading the dumped object returns a Custom instance with its value restored as 1.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.