Lexer gives quoted identifiers an `end` that is the token length, not its end offset

Đang mở
#380 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

@chiliec đang làm issue này rồi.

Từ ngày 12/10/2026.

  • #382 của @chiliec — đang mở
  • #393 của @ApparentlyTejas — đang mở

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
20/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Read jmespath/lexer.py around line 185 and inspect _consume_quoted_identifier; the issue includes a reproducing expression and the incorrect token fields. Check the existing lexer tests for position assertions, then verify the quoted identifier's end is its end offset in foo."q".

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

While testing an experimental version of Perch, we found the following and figured it was worth a report.

_consume_quoted_identifier sets the token's end to the token's length instead of start + length, so it's wrong whenever the identifier isn't at the start of the expression:

>>> from jmespath.lexer import Lexer
>>> [t for t in Lexer().tokenize('foo."q"') if t['type'] == 'quoted_identifier']
[{'type': 'quoted_identifier', 'value': 'q', 'start': 4, 'end': 2}]

end is 2, which is before start. Every other token type uses start + len(...). Search results aren't affected; only the position information is wrong.

It's at jmespath/lexer.py:185:

return {'type': 'quoted_identifier', 'value': loads(lexeme),
        'start': start, 'end': token_len}

'end': start + token_len would fix it. The lexer rewrite in #362 keeps the same line.

Tested on develop (2812594), Python 3.14.6, macOS 26.2.

Ngôn ngữ chính
Python
Star
2.5k
Fork
231
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của jmespath/jmespath.py

Tất cả issue của jmespath/jmespath.py

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.