Skip to content

fix: support creating sparse arrays from empty inputs - #28

Open
iAmMichaelConnor wants to merge 1 commit into
mike/04-fix-mut-lookup-hintsfrom
mike/05-fix-empty-arrays
Open

iAmMichaelConnor wants to merge 1 commit into
mike/04-fix-mut-lookup-hintsfrom
mike/05-fix-empty-arrays

Conversation

@iAmMichaelConnor

Copy link
Copy Markdown
Contributor

Stacked on #27; please review and merge in order.

What

create always sorted its input keys, and sort_advanced cannot be compiled for an empty
array ("Could not determine loop bound at compile-time"), so neither array could be created
without initial entries; an initially empty MutSparseArray is a natural use. Only insert
the sentinels when there are no input keys.

Testing

New test_sparse_lookup_empty and test_create_empty (which also covers size 1, where 0 is
maximum). An empty create fails to compile on master. nargo test (Noir 1.0.0): 26/26
passed.

create() always sorted its input keys, and `sort_advanced` cannot be
compiled for an empty array, so neither array could be created without
initial entries, e.g. an initially empty MutSparseArray. Skip the sort
and value insertion when there are no input keys.
@TomAFrench
TomAFrench force-pushed the mike/05-fix-empty-arrays branch from b2d1778 to 5ec8232 Compare November 3, 2026 03:53
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