Formatter moves a line comment in a switch/if/loop operand into the block
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Estagnada
- Stack de tecnologia
- ocaml
- Domínio
- tooling
Direção de pesquisa
The issue describes the formatter’s line suffix handling and gives operand examples, but names no source files or tests. Start by locating the printer logic that queues trailing line comments and the formatter tests for switch, if, loop, and try operands. Add cases that verify comments stay in the operand across repeated formatting; done means formatting is idempotent for the examples. Pull request #9061 is already open.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
A line comment inside the operand of switch, if, while, for, for..of, for await..of or try moves when formatting: first after the {, then on the next run into the block. Formatting is not idempotent.
switch obj // c
.x {
| _ => ()
}
First run:
switch obj.x { // c
| _ => ()
}
Second run, the comment is now in the block:
switch obj.x {
// c
| _ => ()
}
The same happens with if, while, for..of, for await..of, try (where the comment moves past catch) and with these operands:
obj // c\n.x.yandobj // c\n.x // d\n.yarr[// c\n0],obj[// c\n"member"],obj["member"] // c\n{obj // c\n->fa // c\n+ bfor i in 0 // c\nto n {: the comment moves pastto nand into the loop body
switch f(// c\nx) { is fine, because the arguments group breaks after the comment.
Expected: the comment stays in the operand, for example
switch (
obj.x // c
) {
| _ => ()
}
Cause: the printer queues a trailing line comment as a line suffix and prints it at the next line break of a breaking group. The field access, object get, pipe or binary expression is printed flat with no line break after the comment, so the first break is the one after the block's {.
Found while reviewing #8906, which is about a related case, but this bug is already on master.
- Linguagem predominante
- OCaml
- Estrelas
- 7.5k
- Forks
- 483
- Merge médio
- 20h 50min
- PRs com merge (30d)
- 230
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
-
Create interface drops attributes in front of type declarationsTalvez já em andamento @cknitt assumiu hoje. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 58/100
rescript-lang/rescript#9095 ·
Mantenedores costumam responder em até 1 dia
-
Dev dependencies interactingTalvez já em andamento @CarlOlson assumiu há 1 dia. Aberta
Dificuldade 4/5 1-2 dias Facilidade para iniciantes 25/100
rescript-lang/rescript#9089 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
rescript-lang/rescript#9074 ·
Mantenedores costumam responder em até 1 dia
-
No completion for extensible variant constructorsTalvez já em andamento @cknitt assumiu há 1 dia. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
rescript-lang/rescript#9073 ·
Mantenedores costumam responder em até 1 dia
-
Hover and completion on an applied functor show the functor body's typesTalvez já em andamento @cknitt assumiu há 1 dia. Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
rescript-lang/rescript#9072 ·
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
NRLMMD-GEOIPS/pluginify#41 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 88/100
vigetlabs/wordpress-site-starter#315 ·
Mantenedores costumam responder em até 15 dias
-
enhancement good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
bug good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
NobiResearch/Ovenbird#148 ·
Mantenedores costumam responder em até 1 dia