Fix bug where &i[0] = null was not detected to be an error. #1833

This commit is contained in:
Christoffer Lerno
2025-01-14 01:43:59 +01:00
parent 4cb984e56d
commit 5ba9acad5d
4 changed files with 11 additions and 2 deletions

View File

@@ -140,7 +140,8 @@ enum EventType : (long val)
fn EventType! event_type_from(int val)
{
switch(val) {
switch(val)
{
case EventType.LEFT_MOUSE_DOWN.val: return LEFT_MOUSE_DOWN;
case EventType.LEFT_MOUSE_UP.val: return LEFT_MOUSE_UP;
case EventType.RIGHT_MOUSE_DOWN.val: return RIGHT_MOUSE_DOWN;

View File

@@ -83,6 +83,7 @@
- Fix bug when multiple `$else` clauses followed an `$if` #1824.
- Report the correct type as not having a method when access fails #1828.
- Prevent temp arena scribbling from causing an asan warning. #1825
- Fix bug where `&i[0] = null` was not detected to be an error #1833.
### Stdlib changes
- Increase BitWriter.write_bits limit up to 32 bits.

View File

@@ -510,7 +510,6 @@ static bool sema_binary_is_expr_lvalue(SemaContext *context, Expr *top_expr, Exp
case EXPR_SUBSCRIPT:
case EXPR_SLICE:
case EXPR_SUBSCRIPT_ASSIGN:
case EXPR_SUBSCRIPT_ADDR:
goto CHECK_OPTIONAL;
case EXPR_HASH_IDENT:
if (failed_ref) goto FAILED_REF;
@@ -595,6 +594,7 @@ static bool sema_binary_is_expr_lvalue(SemaContext *context, Expr *top_expr, Exp
case EXPR_VECTOR_TO_ARRAY:
case EXPR_SLICE_TO_VEC_ARRAY:
case EXPR_SCALAR_TO_VECTOR:
case EXPR_SUBSCRIPT_ADDR:
goto ERR;
}
UNREACHABLE

View File

@@ -0,0 +1,7 @@
// Issue #1833
fn int main()
{
int* i;
&i[0] = null; // #error: An assignable expression
return 0;
}