File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -2856,6 +2856,8 @@ pub fn (mut c Checker) expr(node ast.Expr) table.Type {
2856
2856
}
2857
2857
}
2858
2858
return right_type.to_ptr ()
2859
+ } else if node.op == .amp && node.right ! is ast.CastExpr {
2860
+ return right_type.to_ptr ()
2859
2861
}
2860
2862
if node.op == .mul {
2861
2863
if right_type.is_ptr () {
Original file line number Diff line number Diff line change @@ -14,6 +14,26 @@ fn test_ptr_assign() {
14
14
assert v[3 ] == 31
15
15
}
16
16
17
+ fn test_double_ptr () {
18
+ i := 5
19
+ j := 7
20
+ unsafe {
21
+ mut x := & i
22
+ mut p := & x
23
+ (* p) = & j
24
+ assert x == & j
25
+ }
26
+
27
+ // ///////
28
+
29
+ mut x := & int (0 )
30
+ unsafe {
31
+ mut p := & x
32
+ (* p) = & int (1 )
33
+ }
34
+ assert ptr_str (x) == ptr_str (& int (1 ))
35
+ }
36
+
17
37
fn test_ptr_infix () {
18
38
v := 4
19
39
mut q := unsafe {& v - 1 }
You can’t perform that action at this time.
0 commit comments