Nested generic rules get the wrong argument when the outer rule is instantiated more than once
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- devtools
Hướng nghiên cứu
Start by reproducing with the nested.cddl schema and value.cbor (82 81 82 00 01 81 82 00 61 61) using cuddle validate-cbor root value.cbor nested.cddl -f binary. The trace labels the nested instance %inner<x> instead of the substituted argument, so look at how generic rule arguments are substituted and how instances are named and shared during validation. Done when the reproducer prints Validation successful and the existing controls in the table still behave the same.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
When a generic rule passes its parameter on to another generic rule, and the
outer rule is instantiated more than once in the same file with different
arguments, validate-cbor checks the nested rule with the argument of a
different instantiation. Valid CBOR is then rejected.
The validation trace suggests why: the nested instance is labelled with the
outer rule's formal parameter name (%inner<x>) rather than with the
substituted argument (%inner<int>, %inner<tstr>), so all instantiations of
the outer rule seem to share one nested instance.
Version: cuddle 1.8.1.0.
Reproducer
nested.cddl:
root = [a, b]
a = outer<int>
b = outer<tstr>
outer<x> = [inner<x>]
inner<y> = [0, y]
value.cbor is [[[0, 1]], [[0, "a"]]], which matches root:
82 81 82 00 01 81 82 00 61 61
$ cuddle validate-cbor root value.cbor nested.cddl -f binary
array
└ failed to apply required rule:
└ ref: a
└ ref: %outer<int>
└ array
└ failed to apply required rule:
└ ref: %inner<x>
└ array
└ 1 valid elements
failed to apply required rule:
└ failed to apply:
text
Validation failed
Inside a = outer<int>, the nested inner<x> is checked against text, the
argument of the other instantiation (b = outer<tstr>), so the integer 1 is
rejected.
Expected
Validation successful: a is [[0, int]] and b is [[0, tstr]].
Controls
All against [[[0, 1]], [[0, "a"]]] unless noted:
| Variant | Result |
|---|---|
As above (outer instantiated twice, nested generic inner) |
fails |
Only one instantiation (root = a, value [[0, 1]]) |
passes |
outer inlined, no nested generic: outer<x> = [[0, x]] |
passes |
Definitions of a and b in the opposite order |
fails the same way |
root = [b, a] with value [[[0, "a"]], [[0, 1]]] |
fails the same way (%outer<int> → %inner<x> → text) |
inner's parameter also named x (inner<x> = [0, x]) |
fails |
So it takes two instantiations of the outer rule, and the order of the rules
or of the elements doesn't matter. cuddle validate nested.cddl accepts the
schema without complaint.
Where we hit it
ouroboros-consensus describes hard-fork-combinator state with
telescope8<byron, shelley, ..., dijkstra>
= [pastEra, ..., currentEra<dijkstra>] / ...
currentEra<st> = [bound, st]
and uses telescope8 several times in the same file (for the ledger state and
for the chain-dependent state), which has the same shape as the reproducer:
the generic telescope8 passes its parameters on to the generic currentEra.
Valid snapshots were rejected until we worked around it by writing
currentEra<st> out inline as [bound, st] inside telescope8.
- Ngôn ngữ chính
- Haskell
- Star
- 8
- Fork
- 5
- Merge trung bình
- 3 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 4
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
- Đọ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 khác của IntersectMBO/cuddle
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
IntersectMBO/cuddle#168 ·
-
genEnum crashes on empty groupĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
IntersectMBO/cuddle#167 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
IntersectMBO/cuddle#166 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 43/100
IntersectMBO/cuddle#223 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
IntersectMBO/cuddle#217 ·
Tất cả issue của IntersectMBO/cuddle
Issue tương tự
-
agent-ready area:skills
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
jmbarzee/temporal-architect#603 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug dependencies
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
alunduil/network-arbitrary#251 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`logProbability` returns `NaN` for the Poisson distribution with `λ = 0`Có thể đã có người làm @youqad đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
haskell/statistics#235 ·
-
Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100