Question about the intended semantics for inline `#:` type assertions on local variables
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- ドキュメント
- 明瞭さ
- 説明が足りない
- 活発さ
- 静か
- 技術スタック
- ruby
調査の方向性
まず docs/ のインライン構文に関するドキュメントと、ローカル変数のアサーションに関して報告されている Steep および Sorbet の挙動を確認します。Issue の例を比較し、プロジェクトとして1つのセマンティクスを指定すべきか、チェッカー間の違いをドキュメント化すべきかを判断します。完了とは、文書化された決定、またはツールの作成者とユーザーを対象とした、範囲が明確なドキュメント変更があることを意味します。
索引モデルが issue の本文から書いたものです。
説明
Now that inline RBS comments are in ruby/rbs I'd like to clarify what the #: type assertion on a local variable is supposed to mean and to make sure that we aren't baking in a semantic difference between steep and sorbet.
For instance in the following code:
x = "hi" #: String
x = 5
- Steep (verified on
2.0.0) treats#:as a type assertion on the expression (introduced in Steep 1.3 as "declaring the type of an expression inline, without introducing a new local variable with a@type varannotation"). The local remains flow-typed, so the laterx = 5re-infersxtoInteger— no error at the reassignment. - Sorbet (verified on
0.6.13327(RBS comments support) lowersx = v #: Ttox = T.let(v, T).T.letdeclares the local's type for the whole method scope, sox = 5is an error ("Incompatible assignment to variable declared vialet").
This is extra confusing because in the case of
class Foo
attr_accessor :bar #: String?
end
foo = Foo.new
Foo.bar = 5
results in an error in both Steep and Sorbet.
Questions
- Is the semantics of a
#:assertion on a local variable intended to be an expression-level assertion (Steep's behavior), a scope-level declaration/pin (Sorbet'sT.letbehavior), or is it deliberately left to each checker? - If it's left to checkers by design, can we consider documenting that (e.g. in
docs/) so tool authors and users know portability is not guaranteed here? - If a single intended meaning is desired, is there a preference — and would it be worth a note in the inline-syntax docs so Steep/Sorbet/other implementations (RubyMine, and third-party checkers) can converge?
- 主要言語
- Ruby
- スター
- 2.2k
- フォーク
- 258
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 44
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ruby/rbs のほかの issue
-
InlineParser: `@rbs @ivar` annotation is reported as unused unless it is the first thing in the class body対応中かも @ksss が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 22/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
scanaislop/aislop#476 ·
メンテナーはふだん 1 日以内に返信
-
Dependencies view: `getParent` loops forever on untitled documents, extension host runs out of memory対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
area/web interface
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
mastodon/mastodon#41000 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
zerocracy/judges-action#2743 ·
メンテナーはふだん 8 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
endoflife-date/endoflife.date#11314 ·
メンテナーはふだん 1 日以内に返信