We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug It seems that the typechecker eagerly evaluate all indexes when typechecking array access expression in unroll_for! loops.
unroll_for!
To Reproduce
fn array_typecheck_bug() -> u8 { let arr = u8[2][2]:[[u8:0, u8:1], [u8:2, u8:3]]; unroll_for!(x, acc_x): (u2, u8) in u2:0..u2:2 { unroll_for!(y, acc_y): (u2, u8) in u2:0..u2:2 { if y == u2:0 { u8:0 } else { arr[x][y-u2:1] } }(acc_x) }(u8:0) } #[test] fn array_typecheck_bug_test() { assert_eq(array_typecheck_bug(), u8:2); }
will produce the following error:
Error: INVALID_ARGUMENT: Index out of bounds; index: 3 >= 2 elements; lhs: [u8:0, u8:1]; while processing index; while evaluating: { if u2:0 == u2:0 { u8:0 } else { arr[u2:0][u2:0 - u2:1] } } === Source Location Trace: === xls/common/status/status_builder.cc:197 xls/dslx/interp_value.cc:623 xls/dslx/bytecode/bytecode_interpreter.cc:882 xls/dslx/bytecode/bytecode_interpreter.cc:346 xls/dslx/bytecode/bytecode_interpreter.cc:211 xls/dslx/bytecode/bytecode_interpreter.cc:152 xls/dslx/constexpr_evaluator.cc:702 xls/dslx/constexpr_evaluator.cc:232 xls/dslx/constexpr_evaluator.cc:624 xls/dslx/constexpr_evaluator.cc:232 xls/dslx/type_system/deduce.cc:399 xls/dslx/type_system/deduce.cc:2123 xls/dslx/type_system/deduce.cc:2137 xls/dslx/type_system/deduce_ctx.cc:131 xls/dslx/type_system/deduce.cc:832 xls/dslx/type_system/deduce.cc:2123 xls/dslx/type_system/deduce.cc:2137 xls/dslx/type_system/deduce_ctx.cc:131 xls/dslx/type_system/deduce.cc:902 xls/dslx/type_system/deduce.cc:2123 xls/dslx/type_system/deduce.cc:2137 xls/dslx/type_system/deduce_ctx.cc:131 xls/dslx/type_system/deduce_ctx.cc:186 xls/dslx/type_system/deduce.cc:550 xls/dslx/type_system/deduce.cc:666 xls/dslx/type_system/deduce.cc:2123 xls/dslx/type_system/deduce.cc:2137 xls/dslx/type_system/deduce_ctx.cc:131 xls/dslx/type_system/deduce.cc:832 xls/dslx/type_system/deduce.cc:2123 xls/dslx/type_system/deduce.cc:2137 xls/dslx/type_system/deduce_ctx.cc:131 xls/dslx/type_system/deduce.cc:902 xls/dslx/type_system/deduce.cc:2123 xls/dslx/type_system/deduce.cc:2137 xls/dslx/type_system/deduce_ctx.cc:131 xls/dslx/type_system/deduce_ctx.cc:186 xls/dslx/type_system/deduce.cc:379 xls/dslx/type_system/deduce.cc:2123 xls/dslx/type_system/deduce.cc:2137 xls/dslx/type_system/deduce_ctx.cc:131 xls/dslx/type_system/deduce.cc:832 xls/dslx/type_system/deduce.cc:2123 xls/dslx/type_system/deduce.cc:2137 xls/dslx/type_system/deduce_ctx.cc:131 xls/dslx/type_system/deduce.cc:902 xls/dslx/type_system/deduce.cc:2123 xls/dslx/type_system/deduce.cc:2137 xls/dslx/type_system/deduce_ctx.cc:131 xls/dslx/type_system/deduce_ctx.cc:186 xls/dslx/type_system/deduce.cc:550 xls/dslx/type_system/deduce.cc:666 xls/dslx/type_system/deduce.cc:2123 xls/dslx/type_system/deduce.cc:2137 xls/dslx/type_system/deduce_ctx.cc:131 xls/dslx/type_system/deduce.cc:832 xls/dslx/type_system/deduce.cc:2123 xls/dslx/type_system/deduce.cc:2137 xls/dslx/type_system/deduce_ctx.cc:131 xls/dslx/type_system/deduce.cc:902 xls/dslx/type_system/deduce.cc:2123 xls/dslx/type_system/deduce.cc:2137 xls/dslx/type_system/deduce_ctx.cc:131 xls/dslx/type_system/deduce_ctx.cc:186 xls/dslx/type_system/typecheck_function.cc:198 xls/dslx/type_system/typecheck_module.cc:326 xls/dslx/type_system/typecheck_module.cc:326 xls/dslx/parse_and_typecheck.cc:98 xls/dslx/interpreter_main.cc:199
even though the y index will never be u2:0 when the if expression resolve the its second branch.
y
u2:0
if
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
It seems that the typechecker eagerly evaluate all indexes when typechecking array access expression in
unroll_for!
loops.To Reproduce
will produce the following error:
even though the
y
index will never beu2:0
when theif
expression resolve the its second branch.The text was updated successfully, but these errors were encountered: