diff --git a/lib/std/os/macos/objc.c3 b/lib/std/os/macos/objc.c3 index 890782140..48e2aa0a0 100644 --- a/lib/std/os/macos/objc.c3 +++ b/lib/std/os/macos/objc.c3 @@ -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; diff --git a/releasenotes.md b/releasenotes.md index 2cdb5c99a..ad648ee18 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -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. diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index 27334300c..64ae568ec 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -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 diff --git a/test/test_suite/expressions/assign_to_address.c3 b/test/test_suite/expressions/assign_to_address.c3 new file mode 100644 index 000000000..77150c3a2 --- /dev/null +++ b/test/test_suite/expressions/assign_to_address.c3 @@ -0,0 +1,7 @@ +// Issue #1833 +fn int main() +{ + int* i; + &i[0] = null; // #error: An assignable expression + return 0; +} \ No newline at end of file