You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Types] Vec<u8> annotation rejects Vec::with_capacity and cascades into undefined-binding errors #50
Adding an explicit Vec<u8> annotation to a working bounded byte encoder makes Vec::with_capacity(52) fail type checking. This was reproduced while simplifying AgoraSeal's external-verifier context encoding.
The failure should either be resolved through expected-element-type propagation or have a precise documented constructor boundary and actionable diagnostic. It should not cascade into errors for every later use of the binding.
Reproduction
Tested on 2026-10-07 with the local cellc binary reporting 0.31.0, metadata schema 72; compiler checkout HEAD 35bf983. These are local binary results, not a fresh release-build attestation.
let mut context: Vec<u8> = Vec::with_capacity(52)
for i in 8..44 {
context.push(ckb::cell_data_u8(ballot, i) as u8)
}
Keep the subsequent sixteen height-byte pushes, trusted verifier call, and package manifest unchanged. Repin only the isolated copy after this intentional source change, then compile:
error: type mismatch: expected Named("Vec<u8>"), found Named("Vec")
--> src/main.cell:53:9
The complete package reports 19 diagnostics, including subsequent undefined variable 'context' errors.
Removing only : Vec<u8> makes the same package compile successfully. Using unannotated Vec::new() also compiles, and produces the same ELF hash as unannotated Vec::with_capacity(52) in this reproduction.
The constructor type-checking branch should be inspected for loss of element-type information: the local ("Vec", "with_capacity") branch returns Type::Named("Vec".to_string()). This is an investigation lead, not a complete root-cause analysis.
Expected behavior and acceptance
Define and document whether expected Vec<T> types propagate into Vec::new() and Vec::with_capacity(n) for supported fixed-width local elements.
Support the annotated Vec<u8> case above, or provide an explicitly documented alternative with a targeted diagnostic if this combination is intentionally excluded.
Preserve rejection of incompatible pushed element types and unsupported element layouts.
Avoid the undefined-binding diagnostic cascade after a constructor type mismatch.
Keep CLI, recovering diagnostics/LSP, metadata, and the collection support matrix consistent.
Add focused constructor/contextual-typing regressions; run the applicable project gates for the eventual fix.
This issue does not request Rust heap allocation semantics. CellScript currently documents fixed stack-backed local Vec capacity (256 / element_width); with_capacity(52) is not a declaration of an exact 52-byte backing buffer. See the collection support matrix.
Related: #23 (generic authoring), #47 (allocation-backed collections, a separate scope).
Completed on the 0.32 development branch in 670953c2.
Expected Vec<T> types now propagate into Vec::new() and Vec::with_capacity(n) for supported fixed-width local elements. Invalid constructor arguments, incompatible pushed elements and unsupported layouts retain targeted errors; recovering diagnostics and LSP no longer cascade into undefined-binding errors. The existing fixed stack-backed capacity model is unchanged.
Activity
a19q3 commentedon Oct 17, 2026
Completed on the
0.32development branch in 670953c2.Expected
Vec<T>types now propagate intoVec::new()andVec::with_capacity(n)for supported fixed-width local elements. Invalid constructor arguments, incompatible pushed elements and unsupported layouts retain targeted errors; recovering diagnostics and LSP no longer cascade into undefined-binding errors. The existing fixed stack-backed capacity model is unchanged.Evidence: three constructor/CLI/LSP regressions, documented collection contract, and annotated AgoraSeal encoding example. All three regressions and the unified local
cigate passed again during the 2026-10-17/18 acceptance run. This closes the constructor typing/diagnostic issue; it does not introduce heap allocation semantics.