feat: Variadic concat#7231
Open
jbencin-stacks wants to merge 9 commits into
Open
Conversation
`concat` now accepts 2 or more sequence arguments when running under `ClarityVersion::Clarity6`. The 2-argument case is byte-for-byte equivalent to the previous v205 implementation, so older-version contracts running at Epoch 4.0 see no behavior change. The variadic form is folded left-to-right, charging the v205 cost formula on every fold step. This means `(concat a b c)` costs the same as the equivalent `(concat (concat a b) c)` — no arbitrage between the two syntactic forms — while still benefiting from a single allocation path at runtime. Implementation: - Runtime: new `special_concat_v600` in `functions/sequences.rs`; `special_concat` now dispatches by epoch (v200 for 2.0, v205 for 2.05–3.4, v600 for 4.0+). - Type checker: `check_special_concat` switches to `check_arguments_at_least(2)` for Clarity 6+ and folds `least_supertype` / `max_len` across all args. The 2-arg path is preserved exactly for older versions. Tests cover variadic over buff, string-ascii, and list; arity errors (0 and 1 arg); mixed-type rejection at both runtime and analysis time; and a regression check that pre-Clarity-6 contracts still reject 3-arg `concat`. Closes stacks-network#7112 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Coverage Report for CI Build 26460113011Coverage decreased (-38.4%) to 47.53%Details
Uncovered Changes
Coverage Regressions88736 previously-covered lines in 345 files lost coverage.
Coverage Stats
💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Allow
concatto take variable arguments. This allows much cleaner and more efficient buffer building than in Clarity 5:Applicable issues
Additional info (benefits, drawbacks, caveats)
This change means that buffer building costs now scale linearly with the number of arguments, rather than quadratically, since we can eliminate doing a buffer allocation for each argument. We may wish to update the costs contract to reflect the changes
Checklist
docs/property-testing.md)changelog.d/README.md)rpc/openapi.yamlfor RPC endpoints,event-dispatcher.mdfor new events)clarity-benchmarkingrepo