@directive is dropped on @this functions
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, ocaml
- Ambito
- compilers
Direzione di ricerca
Start with the Pjs_fn_method case in compiler/core/lam_compile.ml, then follow how E.method_ builds functions in compiler/core/js_exp_make.ml and how the method branch prints them in Js_dump.pp_function. Check the frontend @this rewrite to confirm the directive stays on the inner function; printlambda does not show directives. Done means @directive appears first in the generated method body, before let self = this, for both examples while preserving async.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
A @this function loses its @directive. Nothing is reported, and async on the same function is kept.
let plain = @this @directive("'use cache'") (self, x) => self + x
let action = @this @directive("'use server'") async (self, x) => self + x
compiles to
function plain(x) {
let self = this ;
return self + x | 0;
}
async function action(x) {
let self = this ;
return self + x | 0;
}
Neither directive appears in the output. Without @this, the directive is kept (function d(n) { 'use cache'; … }).
Cause
@this compiles through %unsafe_to_method to Pjs_fn_method, and that path drops the directive:
compiler/core/lam_compile.ml: thePjs_fn_methodcase matchesattr = {return_unit; async}and never readsdirective.compiler/core/js_exp_make.ml:E.method_has nodirectiveparameter and builds the function withdirective = None.
Fixing it
Passing the directive through is not enough. In Js_dump.pp_function, the method branch prints let self = this before function_body ?directive. The directive would then not be the first statement in the body, so JavaScript would treat it as a plain string expression. The method branch has to print the directive before let self = this.
printlambda does not show directives, so check that the @this rewrite in the frontend keeps the attribute on the inner function.
Found while reviewing #9176, which fixes the related #9174 (forwarding async/directive functions reduced away). This bug was there before that PR.
- Lingua principale
- OCaml
- Stelle
- 7.5k
- Fork
- 485
- Merge medio
- 17h 9m
- PR unite (30g)
- 264
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la 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 rescript-lang/rescript
-
Exception analysis does not know the Temporal `fromStringOrThrow` functionsForse già presa @cknitt l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
rescript-lang/rescript#9182 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
rescript-lang/rescript#9233 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
rescript-lang/rescript#9230 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
rescript-lang/rescript#9229 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 44/100
rescript-lang/rescript#9228 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di rescript-lang/rescript
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
I maintainer di solito rispondono entro 1 giorno
-
A match arm above the largest i64 is compared as 0Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
paradigmxyz/solar#2436 ·
I maintainer di solito rispondono entro 1 giorno
-
bug bulk-filed needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 2 giorni
-
area:codegen backend:slang bug direction:output
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
I maintainer di solito rispondono entro 1 giorno