Error labels inside f-strings and s-strings shift left after escape sequences or triple quotes
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start in prqlc/prqlc-parser/src/parser/expr.rs around the interpolation::parse(string, span + 2) call, then inspect the lexer’s TokenKind::Interpolation data and interpolation parsing. Reproduce the reported f-string and s-string cases with escapes and triple quotes, and trace how decoded content maps to source spans. Done means error labels point to the actual expression column for all listed forms without regressing existing interpolation behavior.
索引モデルが issue の本文から書いたものです。
説明
Error labels inside an f-string or s-string point at the wrong column when the string has escape sequences or uses triple quotes before the {expr}. Each escape sequence moves the label one column left. Triple quotes move it two columns left.
from t
select {x}
derive {y = f"\t\t\t\t{foo}"}
On main (556b1458) the error points at column 20, which is the first \t. foo actually starts at column 24:
3 │ derive {y = f"\t\t\t\t{foo}"}
│ ─┬─
│ ╰─── Unknown name `foo`
The same query written as f"aaaa{foo}" labels column 20, which is correct. f"""aaaa{foo}""" also labels column 20, but there foo starts at column 22. s"…" behaves the same way.
Cause. expr.rs#L223 calls interpolation::parse(string, span + 2). That assumes the string's content starts two characters after the token: one for the f/s prefix and one for the quote. It also assumes each character of string maps to one character of the source. Both assumptions break:
TokenKind::Interpolation(char, String)holds the string after the lexer has decoded escapes, so\t(two source characters) becomes a single character.- A triple-quoted string has two more opening quotes than the
+ 2allows for.
A fix would need the lexer to keep enough information to map positions in the decoded content back to source positions: at least the opening quote count, plus an offset table for escapes or the raw slice. TokenKind::Interpolation is the natural place to carry it. Changing that token is a design choice, so this is filed as an issue rather than a direct PR.
The nightly run 36975211955 found this but was stopped by a usage limit before it could act. The repro above was re-run on main at 556b1458. #6383 changes how malformed escapes are decoded but not the span offset, so it doesn't overlap.
- 主要言語
- Rust
- スター
- 10.9k
- フォーク
- 261
- 平均マージ
- 3日 20時間
- マージ済み PR(30日)
- 85
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PRQL/prql のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 3 日以内に返信
-
prqlc Debug Report HTML Does Not Escape Source File Name, Enabling Stored XSS via PRQLC_DEBUG_LOGオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 3 日以内に返信
-
friendliness integrations
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
PRQL/prql#1636 · コメント 2 件 · リアクション 2 件 ·
メンテナーはふだん 3 日以内に返信
-
tend-rate-limit
難易度 5/5 1週間以上 初心者へのやさしさ 4/100
メンテナーはふだん 3 日以内に返信
-
難易度 4/5 1〜2日 初心者へのやさしさ 12/100
メンテナーはふだん 3 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
libnativeapi/nativeapi#21 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
longbridge/nsh#804 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信