Skip to content

feat: array slicing and concatenation (V16)#3286

Draft
mohammadfawaz wants to merge 1 commit into
stagingfrom
feat/array-slice-concat-v16
Draft

feat: array slicing and concatenation (V16)#3286
mohammadfawaz wants to merge 1 commit into
stagingfrom
feat/array-slice-concat-v16

Conversation

@mohammadfawaz

@mohammadfawaz mohammadfawaz commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Adds native array slicing and concatenation, gated to ConsensusVersion::V16. Additive and backwards-compatible.

Slice — r[a..b] range access (Access::Range)

Half-open, constant u32 bounds, yields [T; b-a]. Read-only; composes with further accesses.

// r0 : [u8; 5]
slice:        r0[1u32..4u32]        // -> [u8; 3]
nested:       r0[1u32..3u32]        // [[u8;2];4] -> [[u8;2];2]  (outer dim)
compose:      r0[1u32..4u32][0u32]  // slice, then index -> u8

Concat — flattening cast

When casting to [T; n], an operand of type T is one element; an operand of type [T; k] is flattened into its k elements (one level). Whole-match takes priority, so the target type decides the shape.

// concat: [u8;2] ++ [u8;3] -> [u8;5]
cast r0 r1 into r2 as [u8; 5u32];

// prepend a scalar: u8 ++ [u8;3] -> [u8;4]
cast r0 r1 into r2 as [u8; 4u32];

// whole-match (no flatten): three [u8;2] -> [[u8;2];3]
cast r0 r1 r2 into r3 as [[u8; 2u32]; 3u32];

Composition

// remove element at index 2 from [u8;5]
cast r0[0u32..2u32] r0[3u32..5u32] into r1 as [u8; 4u32];

Tests in synthesizer/src/vm/tests/test_v16/.

@mohammadfawaz mohammadfawaz self-assigned this Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant