mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Added check when omitting end index for pointers.
This commit is contained in:
committed by
Christoffer Lerno
parent
ce68bda86c
commit
7853cb09ac
@@ -852,6 +852,11 @@ static inline bool sema_expr_analyse_slice_after_parent_resolution(Context *cont
|
||||
SEMA_ERROR(expr->slice_expr.start, "Indexing from the end is not allowed for pointers.");
|
||||
return false;
|
||||
}
|
||||
if (!end)
|
||||
{
|
||||
SEMA_ERROR(expr, "Omitting end index is not allowed for pointers.");
|
||||
return false;
|
||||
}
|
||||
if (end && expr->slice_expr.end_from_back)
|
||||
{
|
||||
SEMA_ERROR(expr->slice_expr.end, "Indexing from the end is not allowed for pointers.");
|
||||
|
||||
@@ -60,6 +60,7 @@ func void test10()
|
||||
{
|
||||
int* x = nil;
|
||||
x[-10..-3];
|
||||
int[] w = x[0..]; // #error: Omitting end index is not allowed for pointers.
|
||||
int[] z = x[^2..]; // #error: Indexing from the end is not allowed for pointers.
|
||||
int[] y = x[..^2]; // #error: Indexing from the end is not allowed for pointers.
|
||||
}
|
||||
Reference in New Issue
Block a user