checker: allow for `unsafe {*(p+1) = 22}` (#10557)

pull/10559/head
BigBlack 2021-06-24 17:39:42 +08:00 committed by GitHub
parent 5a308005d5
commit 8324a766e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -1599,6 +1599,9 @@ fn (mut c Checker) fail_if_immutable(expr ast.Expr) (string, token.Position) {
ast.StructInit {
return '', pos
}
ast.InfixExpr {
return '', pos
}
else {
if !expr.is_lit() {
c.error('unexpected expression `$expr.type_name()`', expr.position())

View File

@ -7,6 +7,8 @@ fn test_pointer_arithmetic() {
assert 2 == *parr
parr++
assert 3 == *parr
parr_add_one := *(parr + 1)
assert parr_add_one == 4
assert *(parr + 1) == 4
}
}