Drop the unused init@ field from classes with a self identifier
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 55/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- fsharp, javascript, python
- 領域
- compilers
調査の方向性
Start by tracing how Fable represents class fields and constructor parameters in its AST, then follow the code that emits the init@ field for JavaScript and Python. Check the constructor handling described in #5235, including how precompiled classes signal a self identifier. Done means the unused field, parameter, argument, and assignment are omitted from generated output while that signal remains available.
索引モデルが issue の本文から書いたものです。
説明
F# adds a hidden init@<line> field to a class whose constructor has a self identifier (type P() as this or new () as self). .NET uses it to throw InvalidOperationException when this is used before the object is fully initialised. The check is a FailInit() call inside the member bodies, so M throws when called from P's constructor:
type P() as this =
let x = this.M()
member _.M() = 1
member _.X = x
Fable emits the field and sets it, but never reads it. The typed tree Fable gets from FCS doesn't contain the FailInit() check, so there is nothing to translate. On JS:
export class P {
constructor() {
const this$ = new FSharpRef(defaultOf());
this$.contents = this;
this.x = (P__M(this$.contents) | 0);
this["init@3"] = 1;
}
}
export function P__M(_) {
return 1;
}
With an explicit constructor (#5235), the field is also a constructor parameter:
export class E {
constructor(Count, init$00408$002D1) {
this.Count = (Count | 0);
this["init@8-1"] = (init$00408$002D1 | 0);
}
}
export function E_$ctor_Z524259A4(a) {
const self = new FSharpRef(defaultOf());
let this$_1;
const this$ = new E(a, 0);
self.contents = this$;
this$["init@8-1"] = 1;
// ...
}
Python emits the same shape (self.init_004039 = init_004039).
Since Fable can't use the field, we could drop it from the output: the class fields, the constructor parameter, the argument in the record construction and the Set. That saves a property per object and a write per construction.
Something to check when doing it: #5235 uses the init@ field of a precompiled class to detect that its constructor has a self identifier, because precompiled libraries don't keep constructor bodies. Removing it from the Fable AST must not remove that signal.
- 主要言語
- F#
- スター
- 3.2k
- フォーク
- 335
- 平均マージ
- 19時間 39分
- マージ済み PR(30日)
- 158
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fable-compiler/Fable のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
fable-compiler/Fable#5280 ·
メンテナーはふだん 1 日以内に返信
-
agentic-workflows automation repo-assist
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
fable-compiler/Fable#4531 ·
メンテナーはふだん 1 日以内に返信
-
agentic-workflows automation repo-assist
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
fable-compiler/Fable#4522 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
fable-compiler/Fable#5286 ·
メンテナーはふだん 1 日以内に返信
-
for loop bound still differs from .NET for reassigned mutable arrays対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 36/100
fable-compiler/Fable#5285 ·
メンテナーはふだん 1 日以内に返信
fable-compiler/Fable の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
tree-sitter/tree-sitter-cpp#381 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
-
new issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
llvm/llvm-project#240065 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
CanadaHonk/porffor#452 ·