Regression: IntegerNode values are incorrect after syntax errors
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #4332 của @kddnewton — đã merge
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 57/100
Hướng nghiên cứu
Start by reproducing the incorrect IntegerNode values with Prism 2.1.0 using the examples Prism.parse("1 2 3") and Prism.parse("1i 2i 3i"), then compare the relevant parser behavior with Prism 1.9.0. The issue does not name source files or tests, so trace integer literal parsing and its regression coverage from the parser entry point. Done means each IntegerNode retains the value at its own source location, including when syntax errors are present.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Affected version: Prism 2.1.0
Known working version: Prism 1.9.0
In Prism 2.1.0, parsing consecutive integer literals separated by whitespace produces an AST with incorrect values for some IntegerNode instances.
Reproduction
Prism.parse("1 2 3")
Prism.parse("1i 2i 3i")
In Prism 2.1.0, the resulting AST contains:
@ StatementsNode (location: (1,0)-(1,5))
├── flags: ∅
└── body: (length: 3)
├── @ IntegerNode (location: (1,0)-(1,1))
│ ├── flags: newline, static_literal, decimal
│ └── value: 2
├── @ IntegerNode (location: (1,2)-(1,3))
│ ├── flags: newline, static_literal, decimal
│ └── value: 2
└── @ IntegerNode (location: (1,4)-(1,5))
├── flags: newline, static_literal, decimal
└── value: 3,
@ StatementsNode (location: (1,0)-(1,8))
├── flags: ∅
└── body: (length: 3)
├── @ ImaginaryNode (location: (1,0)-(1,2))
│ ├── flags: newline, static_literal
│ └── numeric:
│ @ IntegerNode (location: (1,0)-(1,1))
│ ├── flags: static_literal, decimal
│ └── value: 2
├── @ ImaginaryNode (location: (1,3)-(1,5))
│ ├── flags: newline, static_literal
│ └── numeric:
│ @ IntegerNode (location: (1,3)-(1,4))
│ ├── flags: static_literal, decimal
│ └── value: 3
└── @ ImaginaryNode (location: (1,6)-(1,8))
├── flags: newline, static_literal
└── numeric:
@ IntegerNode (location: (1,6)-(1,7))
├── flags: static_literal, decimal
└── value: 3,
The first node represents the literal 1, but its value is 2.
FloatNode and RationalNode nodes generate correct values in a similar case.
Comparison with Prism 1.9.0
This behavior does not occur in Prism 1.9.0.
@ StatementsNode (location: (1,0)-(1,5))
├── flags: ∅
└── body: (length: 3)
├── @ IntegerNode (location: (1,0)-(1,1))
│ ├── flags: newline, static_literal, decimal
│ └── value: 1
├── @ IntegerNode (location: (1,2)-(1,3))
│ ├── flags: newline, static_literal, decimal
│ └── value: 2
└── @ IntegerNode (location: (1,4)-(1,5))
├── flags: newline, static_literal, decimal
└── value: 3,
@ StatementsNode (location: (1,0)-(1,8))
├── flags: ∅
└── body: (length: 3)
├── @ ImaginaryNode (location: (1,0)-(1,2))
│ ├── flags: newline, static_literal
│ └── numeric:
│ @ IntegerNode (location: (1,0)-(1,1))
│ ├── flags: static_literal, decimal
│ └── value: 1
├── @ ImaginaryNode (location: (1,3)-(1,5))
│ ├── flags: newline, static_literal
│ └── numeric:
│ @ IntegerNode (location: (1,3)-(1,4))
│ ├── flags: static_literal, decimal
│ └── value: 2
└── @ ImaginaryNode (location: (1,6)-(1,8))
├── flags: newline, static_literal
└── numeric:
@ IntegerNode (location: (1,6)-(1,7))
├── flags: static_literal, decimal
└── value: 3,
Expected behavior
Each IntegerNode should retain the value corresponding to its own source location, even when the input contains syntax errors.
Since Prism 1.9.0 handled these cases correctly, this appears to be a regression introduced in a later version.
- Ngôn ngữ chính
- C
- Star
- 1k
- Fork
- 202
- Merge trung bình
- 7 giờ 52 phút
- Pull request đã merge (30 ngày)
- 76
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
contrib/ivorysql_ora/src/builtin_packages/utl_file/utl_file.c:517 - FCOPY destroys a file when source and destination are the sameCó thể đã có người làm @Metastarx đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
ly05010419/MacNativeGames#1848 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
libc++ test-suite
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
llvm/llvm-project#239851 ·
Maintainer thường phản hồi trong vòng 1 ngày