Constants defined under a payload alias (YAML = Psych) are emitted under the alias name, rejected by sorbet >= 0.6.13550
维护者通常 4 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start by reading Tapioca’s gem RBI generation path and how it resolves constant namespaces; the issue identifies the generated nested constant as the failing case. Reproduce with bundle exec tapioca gem yaml and bundle exec srb tc using the stated versions. Done means the generated RBI handles YAML::LOADER_VERSION without Sorbet error 4022 while the constant remains accessible as a String through YAML.
由索引模型根据 Issue 内容生成。
描述
Summary
Since sorbet 0.6.13550 (sorbet/sorbet#10758; related: sorbet/sorbet#10767 for the net-http counterpart), Sorbet rejects any definition nested under a payload constant alias. The yaml gem RBI that tapioca generates now fails srb tc:
sorbet/rbi/gems/[email protected]:9: Redefining constant `YAML` as a class or module https://srb.help/4022
https://github.com/sorbet/sorbet/tree/b3a38a5fcb5cfeadd9031b3ddf513547f2c2f229/rbi/stdlib/yaml.rbi#L62: Previously defined as a static field here
62 |YAML = Psych # :nodoc:
Reproduction
- tapioca 0.20.0, sorbet 0.6.13550, Ruby 4.0.6,
yaml0.4.0 (a dependency ofpagy) bundle exec tapioca gem yamlgenerates:
# pkg:gem/yaml#lib/yaml.rb:69
YAML::LOADER_VERSION = T.let(T.unsafe(nil), String)
bundle exec srb tcreports the 4022 error above. Minimal case without tapioca: sorbet.run. sorbet 0.6.13544 accepts it.
The gem's lib/yaml.rb does YAML = Psych and later module YAML; LOADER_VERSION = "0.4.0"; end. At runtime YAML.equal?(Psych) is true, so the constant really lives on Psych.
Expected
When the namespace is an alias, tapioca should emit the constant under the alias target's real name (Psych::LOADER_VERSION = T.let(T.unsafe(nil), String)). Sorbet 0.6.13550 accepts that, and YAML::LOADER_VERSION still resolves to String. Alternatively, it could skip constants whose namespace is a payload alias.
Tapioca 0.20.0 already drops the module YAML; end line that older versions emitted. The same reasoning has to cover nested constants.
- 主要语言
- Ruby
- 星标
- 874
- 派生
- 167
- 平均合并
- 5 天 12 小时
- 30 天内合并 PR
- 11
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Shopify/tapioca 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
Shopify/tapioca#2662 · 1 条评论 ·
维护者通常 4 天内回复
-
Option to omit private methods from gem RBIs, with a per-gem opt-in可能已有人在做 @efegokdemir 于 2 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 30/100
维护者通常 4 天内回复
-
Improve `check-shims` performance可能已有人在做 @KaanOzkan 于 16 天前认领。 未关闭
Shopify/tapioca#2728 · 已指派 1 人 ·
维护者通常 4 天内回复
-
难度 5/5 一周以上 新手友好度 30/100
维护者通常 4 天内回复
-
Prepending a module can cause `tapioca dsl` to produce an untyped signature可能已有人在做 @KaanOzkan 于 51 天前认领。 未关闭bug
Shopify/tapioca#2705 · 已指派 1 人 ·
维护者通常 4 天内回复
相似的 Issue
-
message-patterns
难度 2/5 1-3 小时 新手友好度 65/100
sisimai/rb-sisimai#468 ·
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 7 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 7 天内回复
-
bugsnag
难度 2/5 1-3 小时 新手友好度 62/100
JoeMcB/improvcoaches#827 ·
-
难度 1/5 1 小时以内 新手友好度 72/100
TheOdinProject/curriculum#31465 ·
维护者通常 1 天内回复