Record coercion can construct a private record from outside its module
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #9125 @cknitt による — マージ済み
評価
- 難易度
- 4/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- ocaml
- 領域
- compilers
調査の方向性
Start by tracing the record coercion type-checking path in the ReScript compiler and compare it with the handling of mutable from #9063, fixed by #9086. Check both examples in this issue: coercion from a plain record and from another module’s private record should be rejected, while coercion out to a plain record should remain allowed. Done means those cases behave as expected and the compiler’s relevant regression tests pass.
索引モデルが issue の本文から書いたものです。
説明
A record coerces structurally into a private record with the same fields, so code outside a module can construct values of that module's private record type, although private means they can only be built inside it.
From a plain record:
module Blob: {
type t = private {size: float}
} = {
type t = {size: float}
}
type plain = {size: float}
let fake = (p: plain): Blob.t => (p :> Blob.t) // compiles: `return p`
From another module's private record with the same fields, which that module constructs freely:
module Fake: {
type t = private {size: float}
let make: float => t
} = {
type t = {size: float}
let make = size => {size: size}
}
let forged = (Fake.make(1.) :> Blob.t) // compiles: `{size: 1}`
Expected: a coercion into a private record type is refused, unless the source is that same type. Coercing out of a private record, into a plain record with the same fields, stays allowed: reading a private record is fine.
This is a prerequisite for @instanceOf on private records (#9058): there, a forged value would be dispatched as an instance of a class it isn't. It is the same family as #9063 (fixed by #9086), where record coercion ignored mutable.
Found on master 3562ce6b80.
- 主要言語
- OCaml
- スター
- 7.5k
- フォーク
- 484
- 平均マージ
- 21時間 9分
- マージ済み PR(30日)
- 255
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rescript-lang/rescript のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
rescript-lang/rescript#9135 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
rescript-lang/rescript#9132 ·
メンテナーはふだん 1 日以内に返信
-
Printed type declarations drop @tag, @notUndefined and runtime annotations対応中かも @cknitt が今日担当しました。 オープン
難易度 4/5 1〜2日 初心者へのやさしさ 25/100
rescript-lang/rescript#9134 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
rescript-lang/rescript#9130 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 1〜2日 初心者へのやさしさ 55/100
rescript-lang/rescript#9122 ·
メンテナーはふだん 1 日以内に返信
rescript-lang/rescript の issue をすべて見る
似ている issue
-
bug medium priority openmp tokenizer wrong result
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
import: a segment starting with a digit is refused, but the error says digits are allowed対応中かも @sebastianbreguel が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
HigherOrderCO/Bend#1961 ·
-
bug pdd
難易度 2/5 1時間未満 初心者へのやさしさ 60/100
objectionary/eo#9675 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 4 日以内に返信
-
compatibility
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
truffleruby/truffleruby#4502 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信