Menu ▾ ▴

#5800 array assignment for hashed arrays fails to detect inconsistent dimensions

None
open
nobody
5
3 days ago
3 days ago
No

Hashed arrays, as created by make_array(hashed, ...) or implicitly after use_fast_arrays: true, can be assigned with different numbers of indices (e.g. allocated with 1 index and assigned with 2 or vice versa), and the assignment operator doesn't prevent it. Evaluation with those same indices successfully retrieves the values that were assigned, but arrayinfo runs into a Lisp error.

The bug is only triggered if the array is constructed w/ 1 index and assigned w/ 2 or more, or vice versa. If e.g. constructed w/ 2 indices and assigned w/ 3, the bug isn't triggered.

I don't know what's the right solution here. Either to detect the inconsistent indices and prevent the assignment, or fix up arrayinfo to handle varying numbers of indices. On general principal, I'm inclined to allow varying numbers of indices, but restricting to just the same number is consistent with other declared and undeclared array code.

I am also inclined to nuke the existing stuff around the special case for 1-dimensional hash tables. I don't think it buys us anything and makes everything around hashed arrays more complicated.

NB. To declare a multidimensional hashed array, make_array(hashed, 1, 1) i.e. supply 2 or more additional arguments. This is a mess, of course.

Discussion


Log in to post a comment.