Skip to content

Commit

Permalink
Fix case trying to initialize a char[*]* from a String.
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Dec 15, 2024
1 parent 7d153a1 commit 4ae3d01
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
11 changes: 11 additions & 0 deletions releasenotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# C3C Release Notes

## 0.6.6 Change list

### Changes / improvements
None

### Fixes
- Fix case trying to initialize a `char[*]*` from a String.

### Stdlib changes
None

## 0.6.5 Change list

### Changes / improvements
Expand Down
6 changes: 4 additions & 2 deletions src/compiler/sema_casts.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,15 @@ Type *type_infer_len_from_actual_type(Type *to_infer, Type *actual_type)
// And from the actual type.
actual_type = type_no_optional(actual_type);

Type *actual = type_get_indexed_type(actual_type);
if (!actual) return actual_type;

// Grab the underlying indexed type,
// because we can only have [*] [] [<*>] [<>] * here
Type *indexed = type_get_indexed_type(to_infer);
Type *actual = type_get_indexed_type(actual_type);

// We should always have indexed types.
ASSERT0(indexed && actual);
ASSERT0(indexed);

// The underlying type may also be inferred.
// In this case, infer it.
Expand Down
6 changes: 6 additions & 0 deletions test/test_suite/cast/cast_string_to_infered_array.c3
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import std;
fn void main()
{
char[*]* x = "abc"; // #error: You cannot cast 'String' to 'char[*]*'
io::printn($typeof(x).nameof);
}

0 comments on commit 4ae3d01

Please sign in to comment.