Nested generic rules get the wrong argument when the outer rule is instantiated more than once
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 领域
- devtools
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Haskell
- 星标
- 8
- 派生
- 5
- 平均合并
- 3 天 12 小时
- 30 天内合并 PR
- 4
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
IntersectMBO/cuddle 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
IntersectMBO/cuddle#168 ·
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
IntersectMBO/cuddle#167 ·
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
IntersectMBO/cuddle#166 ·
-
难度 4/5 3-5 天 新手友好度 43/100
IntersectMBO/cuddle#223 ·
-
难度 4/5 3-5 天 新手友好度 48/100
IntersectMBO/cuddle#217 ·
查看 IntersectMBO/cuddle 的全部 Issue
相似的 Issue
-
documentation
难度 2/5 1-3 小时 新手友好度 76/100
bittide/bittide-hardware#1357 ·
-
难度 1/5 1 小时以内 新手友好度 76/100
wireapp/wire-server#5690 ·
维护者通常 3 天内回复
-
bug dependencies
难度 2/5 1-3 小时 新手友好度 70/100
alunduil/network-arbitrary#251 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
`logProbability` returns `NaN` for the Poisson distribution with `λ = 0`可能已有人在做 @youqad 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
haskell/statistics#235 ·