Drop the unused init@ field from classes with a self identifier
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- fsharp, javascript, python
- Lĩnh vực
- compilers
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- F#
- Star
- 3.2k
- Fork
- 335
- Merge trung bình
- 19 giờ 39 phút
- Pull request đã merge (30 ngày)
- 158
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của fable-compiler/Fable
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
fable-compiler/Fable#5280 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agentic-workflows automation repo-assist
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
fable-compiler/Fable#4531 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agentic-workflows automation repo-assist
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
fable-compiler/Fable#4522 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
fable-compiler/Fable#5286 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
for loop bound still differs from .NET for reassigned mutable arraysCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 36/100
fable-compiler/Fable#5285 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của fable-compiler/Fable
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
rubys/roundhouse#1950 ·
-
Diagnostics: an ambiguous overloaded call names neither the argument types nor the tied candidatesĐang mởbug priority: P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
-
Upstream report: MSVC rejects a designated initializer in a dependent template argument (C2131)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
rhalbersma/tabula#72 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
tree-sitter/tree-sitter-cpp#381 ·
-
[P2] Interpreter: Array.prototype.findLastIndex starts at the wrong index for long array-likesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày