The monomorphization pass currently contains a check to evaluate the array_len builtin function. This is somewhat odd as it is the only thing the pass will attempt to evaluate. This has caused bugs in the past (#562, #1354), primarily from functions like to_be_bytes that return an array of unknown length (they should be returning slices instead).
Happy Case
We could make array_len a builtin instead and leave the function call in for ssa to optimize if the type is known. This would also more easily allow it to be used for slice types with unknown lengths when they are added. Any calls to array_len remaining in acir_gen can be easily evaluated there as well.
Problem
The monomorphization pass currently contains a check to evaluate the array_len builtin function. This is somewhat odd as it is the only thing the pass will attempt to evaluate. This has caused bugs in the past (#562, #1354), primarily from functions like to_be_bytes that return an array of unknown length (they should be returning slices instead).
Happy Case
We could make array_len a builtin instead and leave the function call in for ssa to optimize if the type is known. This would also more easily allow it to be used for slice types with unknown lengths when they are added. Any calls to array_len remaining in acir_gen can be easily evaluated there as well.
Alternatives Considered
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response