ruby / ruby/rbs

Decls added with `RBS::Environment#<<` disappear after `RBS::Environment#resolve_type_names` in RBS v3 or later

Open
#1,292 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
2.2k
Forks
256
Avg merge
6d 17h
Merged PRs (30d)
37

Description

Decl added using RBS::Environment#<< will disappear from within env after RBS::Environment#resolve_type_names.
But, Decl added using RBS::Environment#add_signature will remain.
Is this intended behavior?

p RBS::VERSION
#=> "3.0.4"

env = RBS::Environment.new
_, _, decls = RBS::Parser.parse_signature("class Foo\nend")
env << decls.first

p env
#=> #<RBS::Environment @declarations=(1 items) @class_decls=(1 items) @class_alias_decls=(0 items) @interface_decls=(0 items) @type_alias_decls=(0 items) @constant_decls=(0 items) @global_decls=(0 items)>

p env.resolve_type_names
#=> #<RBS::Environment @declarations=(0 items) @class_decls=(0 items) @class_alias_decls=(0 items) @interface_decls=(0 items) @type_alias_decls=(0 items) @constant_decls=(0 items) @global_decls=(0 items)>

buffer, directives, decls = RBS::Parser.parse_signature("class Bar\nend")
env.add_signature(buffer: buffer, directives: directives, decls: decls)

p env
#=> #<RBS::Environment @declarations=(2 items) @class_decls=(1 items) @class_alias_decls=(0 items) @interface_decls=(0 items) @type_alias_decls=(0 items) @constant_decls=(0 items) @global_decls=(0 items)>

p env.resolve_type_names
#=> #<RBS::Environment @declarations=(1 items) @class_decls=(1 items) @class_alias_decls=(0 items) @interface_decls=(0 items) @type_alias_decls=(0 items) @constant_decls=(0 items) @global_decls=(0 items)>

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

Reproduce the issue using RBS::Environment#<<, RBS::Environment#resolve_type_names, and RBS::Environment#add_signature with the signatures shown in the report. Inspect the environment state before and after resolution, then determine the intended behavior for declarations added through both APIs and add coverage for the chosen behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.