Shebang callback support in language bindings
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 30/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 活発
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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?
- 主要言語
- C
- スター
- 1k
- フォーク
- 202
- 平均マージ
- 6時間 18分
- マージ済み PR(30日)
- 77
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ruby/prism のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
good first issue help wanted program
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
hffgzktbcc-blip/ounce-core#297 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
coolsnowwolf/lede#14283 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
OpenVisualCloud/SVT-JPEG-XS#130 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
rusefi/rusefi#10602 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信