mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: allow for unsafe {*(p+1) = 22}
(#10557)
This commit is contained in:
parent
5a308005d5
commit
8324a766e8
@ -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())
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user