@directive is dropped on @this functions
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 55/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- javascript, ocaml
- Domínio
- compilers
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- OCaml
- Estrelas
- 7.5k
- Forks
- 485
- Merge médio
- 17h 9min
- PRs com merge (30d)
- 264
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de rescript-lang/rescript
-
Exception analysis does not know the Temporal `fromStringOrThrow` functionsTalvez já em andamento @cknitt assumiu há 1 dia. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
rescript-lang/rescript#9182 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
rescript-lang/rescript#9233 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 55/100
rescript-lang/rescript#9230 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 72/100
rescript-lang/rescript#9229 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 44/100
rescript-lang/rescript#9228 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de rescript-lang/rescript
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 69/100
Mantenedores costumam responder em até 1 dia
-
A match arm above the largest i64 is compared as 0Talvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
paradigmxyz/solar#2436 ·
Mantenedores costumam responder em até 1 dia
-
bug bulk-filed needs triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 2 dias
-
area:codegen backend:slang bug direction:output
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 73/100
Mantenedores costumam responder em até 1 dia