#7614 adds test_types project to in_language_tests. This project utilizes type aliases for arrays along with traits implemented for arrays using const generics.
When those type aliases are used in definition of struct fields, e.g.:
pub struct StructB {
f_struct_a: StructA,
f_tuple: (u8, u16, u32, u64, u256),
// Using type aliases causes below issues.
f_array_u8_len_2: ArrayU8Len2,
f_array_nested_array_u8_len_2_len_3: ArrayNestedArrayU8Len2Len3,
// Not using type aliases does not cause issues.
f_array_u8_len_2: [u8; 2],
f_array_nested_array_u8_len_2_len_3: [[u8; 2]; 3],
}
assigning to those struct fields causes the following ICE and type mismatch errors:
--> sway-lib-std/src/ops.sw:786:23
|
784 | fn eq(self, other: Self) -> bool {
785 | let mut i = 0;
786 | while __lt(i, N) {
| ^ Internal compiler error: Const generic not materialized
Please file an issue on the repository and include the code that triggered this error.
787 | let a: T = *__elem_at(&self, i);
788 | let b: T = *__elem_at(&other, i);
|
error
--> test/src/in_language_tests/test_programs/test_types/src/main.sw:597:64
|
595 | u256_values.get(i).unwrap(),
596 | ),
597 | f_array_u8_len_2: array_u8_len_2_values.get(i).unwrap(),
| ^^^^^^ Mismatched types.
expected: ArrayU8Len2
found: [u8; N].
help: Function return type does not match up with local type annotation.
598 | f_array_nested_array_u8_len_2_len_3:
599 | array_nested_array_u8_len_2_len_3_values.get(i).unwrap(),
|
____
error
--> test/src/in_language_tests/test_programs/test_types/src/main.sw:599:69
|
597 | f_array_u8_len_2: array_u8_len_2_values.get(i).unwrap(),
598 | f_array_nested_array_u8_len_2_len_3:
599 | array_nested_array_u8_len_2_len_3_values.get(i).unwrap(),
| ^^^^^^ Mismatched types.
expected: ArrayNestedArrayU8Len2Len3
found: [ArrayU8Len2; N].
help: Function return type does not match up with local type annotation.
600 | });
601 | i += 1;
|
____
error
--> test/src/in_language_tests/test_programs/test_types/src/main.sw:599:21
|
597 | f_array_u8_len_2: array_u8_len_2_values.get(i).unwrap(),
598 | f_array_nested_array_u8_len_2_len_3:
599 | array_nested_array_u8_len_2_len_3_values.get(i).unwrap(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Mismatched types.
expected: ArrayNestedArrayU8Len2Len3
found: [ArrayU8Len2; N].
help: Function application argument type must match function parameter type.
600 | });
601 | i += 1;
Related to #7604.
#7614 adds
test_typesproject toin_language_tests. This project utilizes type aliases for arrays along with traits implemented for arrays using const generics.When those type aliases are used in definition of struct fields, e.g.:
assigning to those struct fields causes the following ICE and type mismatch errors:
Related to #7604.