harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 8279e1a441a258b1a8abd07331f65b535c42e650
parent e8895c2ff44df822d444d7e1727cb289682a1d94
Author: Bor Grošelj Simić <bgs@turminal.net>
Date:   Sat, 12 Mar 2022 15:33:05 +0100

type_is_assignable: ensure array member types match

Signed-off-by: Bor Grošelj Simić <bgs@turminal.net>

Diffstat:
Msrc/types.c | 3++-
Mtests/01-arrays.ha | 8++++++++
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/types.c b/src/types.c @@ -833,7 +833,8 @@ type_is_assignable(const struct type *to, const struct type *from) && to->array.members == from->array.members; } else { return to->array.length == SIZE_UNDEFINED - && from->array.length != SIZE_UNDEFINED; + && from->array.length != SIZE_UNDEFINED + && to->array.members == from->array.members; } case STORAGE_TAGGED: return tagged_select_subtype(to, from_orig) != NULL diff --git a/tests/01-arrays.ha b/tests/01-arrays.ha @@ -57,6 +57,14 @@ fn assignment() void = { ptr = &b; }; ") != 0); + + assert(rt::compile(` + export fn main() void = { + let a: *[*]uint = &[1u,2u,3u]; + let b: [3]str = ["a", "b", "c"]; + a = &b; + }; + `) != 0); }; fn param(x: [3]int) void = {