Shebang callback support in language bindings
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 30/100
- Tipo de issue
- Funcionalidade
- Clareza
- Precisa de esclarecimento
- Status de atividade
- Ativa
- Domínio
- backend-api-design
Direção de pesquisa
Start with the Rust binding callback branch and the referenced main_script option in ext/prism/extension.c, then compare how Prism’s language bindings handle parser options. The issue asks whether shebang processing belongs in Prism or in each binding, including the effects of flags such as -n on the AST. Done means that design question is resolved and the chosen behavior is supported consistently.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
related to https://github.com/fables-tales/rubyfmt/issues/916
Some files are only syntactically valid after they've been processed with shebang comments, e.g.
#!/usr/bin/env ruby -np
next
Currently, the way these are handled is by passing a shebang_callback which reads the flags and sets the appropriate options (like here in CRuby).
I'd like for rubyfmt to be able to support files like this, and as for the immediate solution it wouldn't be too hard to add support for shebang callbacks in the Rust bindings (I've got a branch with those changes), but I suppose my broader question is whether or not language bindings all having to reinvent shebang handling is the desired end result.
Right now, this example also fails in the prism gem (Prism::parse('#!/usr/bin/env ruby -np\nnext') returns errors), and presumably does the same for all the language bindings, and yet echo '#!/usr/bin/ruby -n\nnext' | ruby -c says the syntax is OK, which is somewhat surprising and leads to things like ruby-lsp also reporting errors on similar files. That said, a reasonable argument for Prism not doing this handling by default is that some shebang flags (like -n) result in nodes being inserted into the AST, and it might not be ideal to do that without some kind of explicit choice -- though as it currently stands it does require the main_script option to be set, which may be sufficient.
So my question is, is the preferred approach for users of Prism to re-implement shebang handling (and it can be exposed as an option by the various language bindings), or is there some world where Prism itself handles shebangs?
- Linguagem predominante
- C
- Estrelas
- 1k
- Forks
- 202
- Merge médio
- 6h 4min
- PRs com merge (30d)
- 81
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem 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.
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
follow-up Prio 📌
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 84/100
Mantenedores costumam responder em até 1 dia
-
area: test kind: bug preview-effort: small priority: low
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
libsdl-org/SDL#16684 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100