Skip to content

Add multiIndexArray builtin (CIP-0156)#7844

Open
Unisay wants to merge 3 commits into
masterfrom
yura/issue-1675-multi-index-array
Open

Add multiIndexArray builtin (CIP-0156)#7844
Unisay wants to merge 3 commits into
masterfrom
yura/issue-1675-multi-index-array

Conversation

@Unisay

@Unisay Unisay commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Adds the multiIndexArray builtin from CIP-0156: forall a. list integer -> array a -> list a, returning the array elements at the given indices in index-list order (duplicates preserved) and failing the whole call on any out-of-bounds index. Bounds are checked in the Integer domain, so a negative index or one exceeding maxBound::Int is out-of-bounds rather than wrapping.

Placeholder costing (unimplementedCostingFun) and gated under futurePV, so it is not available in any released protocol version.

Core language + CEK only; Plinth exposure, costing, conformance, and metatheory are separate follow-ups. Draft — not ready for review.

This comment was marked as outdated.

@Unisay
Unisay marked this pull request as ready for review July 16, 2026 09:10
@Unisay
Unisay force-pushed the yura/issue-1675-multi-index-array branch from 32c205d to eaeb73f Compare July 16, 2026 09:11
@Unisay
Unisay requested a review from a team July 16, 2026 14:06
(runCostingFunTwoArguments . paramScaleValue)
toBuiltinMeaning _semvar MultiIndexArray =
let multiIndexArrayDenotation
:: [Integer] -> SomeConstant uni (Vector a) -> BuiltinResult (Opaque val [a])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Need an explanation of why it uses Integer while indexArray uses Int
  2. The argument order is different from indexArray's and I see no good reason for it.

Unisay added 3 commits July 17, 2026 13:20
`multiIndexArray :: forall a. list integer -> array a -> list a` returns
the array elements at the given indices in order (duplicates preserved),
failing the whole call on any out-of-bounds index. Bounds are checked in
the Integer domain, so an index exceeding maxBound::Int is out-of-bounds
rather than wrapping. Placeholder costing (unimplementedCostingFun) until
benchmarked; not exposed to Plinth.

Adds the CEK denotation, flat tag, and RewriteRules/plugin exhaustiveness
arms, plus regenerated type-synthesis and parser goldens.

Issue: IntersectMBO/plutus-private#1675
New batch7 holds builtins that are implemented but not yet approved for
release, mapped to futurePV in builtinsIntroducedIn for all three ledger
languages. Per Note [Adding new builtins: protocol versions], so
multiIndexArray is not available in any released protocol version. The
Versions specs (and Data twin) expect it rejected at newestPV.

Issue: IntersectMBO/plutus-private#1675
CEK tests covering index order, duplicate indices, polymorphic element
type, empty index list, and the out-of-bounds failure modes
(index == length, negative, and an index exceeding maxBound::Int).

Issue: IntersectMBO/plutus-private#1675
@Unisay
Unisay force-pushed the yura/issue-1675-multi-index-array branch from eaeb73f to b088b82 Compare July 17, 2026 11:29
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.

3 participants