Skip to content

2/2: Add enumerate() to DSLX stdlib#4022

Open
joannabrozek wants to merge 2 commits intogoogle:mainfrom
antmicro:remove-builtin-enumerate
Open

2/2: Add enumerate() to DSLX stdlib#4022
joannabrozek wants to merge 2 commits intogoogle:mainfrom
antmicro:remove-builtin-enumerate

Conversation

@joannabrozek
Copy link
Copy Markdown
Contributor

The second of two PRs responsible for migrating from the built-in enumerate, which cannot be lowered to IR.

This PR includes: removing the build-in enumerate.

@mikex-oss
Copy link
Copy Markdown
Collaborator

Aside from obvious updates to use std:enumerate, I'm seeing the following error in a bunch of our targets.

Not sure yet how to repro this in a small standalone test.

xls/dslx/stdlib/std.x:20:13-20:19
0018: 
0019: pub fn enumerate<T: type, N: u32>(x: T[N]) -> (u32, T)[N] {
0020:     for (i, result) in 0..N {
~~~~~~~~~~~~~~~~~~^----^ TypeInferenceError: TypeInferenceError: xls/dslx/stdlib/std.x:20:13-20:19 Annotated array size is too small for explicit element count.. The body of function `enumerate` does not actually return the function's declared return type, which is `(u32, u32)[N]`
0021:         update(result, i, (i, x[i]))
0022:     }([(u32:0, zero!<T>()), ...])
Error: INVALID_ARGUMENT: TypeInferenceError: xls/dslx/stdlib/std.x:20:13-20:19 TypeInferenceError: xls/dslx/stdlib/std.x:20:13-20:19 Annotated array size is too small for explicit element count.. The body of function `enumerate` does not actually return the function's declared return type, which is `(u32, u32)[N]`
=== Source Location Trace: === 
xls/dslx/errors.cc:48
xls/dslx/type_system_v2/type_annotation_resolver.cc:325
xls/dslx/type_system_v2/inference_table_converter_impl.cc:1077
xls/dslx/type_system_v2/inference_table_converter_impl.cc:269
xls/dslx/type_system_v2/inference_table_converter_impl.cc:884
xls/dslx/type_system_v2/inference_table_converter_impl.cc:245
xls/dslx/type_system_v2/inference_table_converter_impl.cc:884
xls/dslx/type_system_v2/inference_table_converter_impl.cc:245
xls/dslx/type_system_v2/inference_table_converter_impl.cc:2007
xls/dslx/type_system_v2/inference_table_converter_impl.cc:1750
xls/dslx/type_system_v2/inference_table_converter_impl.cc:1835
xls/dslx/type_system_v2/inference_table_converter_impl.cc:737
xls/dslx/type_system_v2/inference_table_converter_impl.cc:245
xls/dslx/import_routines.cc:247
xls/dslx/type_system_v2/populate_table_visitor.cc:136
xls/dslx/type_system_v2/populate_table_visitor.cc:1939
xls/dslx/type_system_v2/typecheck_module_v2.cc:89
xls/dslx/import_routines.cc:247
xls/dslx/type_system_v2/populate_table_visitor.cc:136
xls/dslx/type_system_v2/populate_table_visitor.cc:1939
xls/dslx/type_system_v2/typecheck_module_v2.cc:89
xls/dslx/import_routines.cc:247
xls/dslx/type_system_v2/populate_table_visitor.cc:136
xls/dslx/type_system_v2/populate_table_visitor.cc:1939
xls/dslx/type_system_v2/typecheck_module_v2.cc:89
xls/dslx/parse_and_typecheck.cc:126
xls/dslx/ir_convert/ir_converter.cc:697
xls/dslx/ir_convert/ir_converter_main.cc:159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants