Run base constructor then blocks on the derived instance
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, python, typescript
- Ambito
- compilers
Direzione di ricerca
Read the constructor inheritance handling and the tests from the earlier #5235 branch at 2a69b6a8f; those tests identify the shapes a fix must handle. Reproduce the example on .NET and the #5235 branch, then trace how explicit constructors and base then blocks are compiled. Done means both derived classes compile and produce true and 2, while the listed edge cases remain correct.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
On JS, TS and Python, Fable can't inherit from a class whose explicit constructor has a self identifier, and a class with a base class can't have one. Once #5235 merges, both are compile errors, as they are on main. .NET prints true and 2.
let saved = ResizeArray<obj>()
type Base =
val Name: string
new (name: string) as self = { Name = name } then saved.Add(box self)
type Derived =
inherit Base
val X: int
new () = { inherit Base("d"); X = 1 }
type Counter =
val mutable Count: int
new (c: int) as self = { Count = c } then self.Bump()
member this.Bump() = this.Count <- this.Count + 1
type CounterChild =
inherit Counter
val X: int
new () = { inherit Counter(1); X = 1 }
let d = Derived()
printfn "%b" (obj.ReferenceEquals(saved.[0], d))
printfn "%d" (CounterChild()).Count
On the #5235 branch, both derived classes fail with:
error FABLE: Program.Base has a constructor with a self identifier (`new() as x`), which Fable does not support inheriting from.
Both programs are valid F#. Supporting them means running the base then block on the derived instance. One idea, untested, is to split explicit constructors into separate allocate and initialize steps.
An earlier version of #5235 built a separate base object and copied its fields into the derived one. That was dropped because it gave wrong output for: curried function fields in the derived class, a base behind a .fsi, an [<AttachMembers>] base, and leaking self. It's in the branch history at 2a69b6a8f, and the tests from that version list the shapes a real fix has to handle.
- Lingua principale
- F#
- Stelle
- 3.2k
- Fork
- 335
- Merge medio
- 18h 57m
- PR unite (30g)
- 154
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di fable-compiler/Fable
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
fable-compiler/Fable#5280 ·
I maintainer di solito rispondono entro 1 giorno
-
agentic-workflows automation repo-assist
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
fable-compiler/Fable#4531 ·
I maintainer di solito rispondono entro 1 giorno
-
agentic-workflows automation repo-assist
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
fable-compiler/Fable#4522 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
fable-compiler/Fable#5281 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 57/100
fable-compiler/Fable#5279 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di fable-compiler/Fable
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
compiler: `void` inside a constant array or object literal throws in `PureFunctionConstant.keyOf`Apertaarea: compiler
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
segfaultcafe/flecha#208 ·
I maintainer di solito rispondono entro 1 giorno
-
bug gc sev-3
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
S3: friction & debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
MedakaLang/medaka#4940 ·
I maintainer di solito rispondono entro 1 giorno