|
| 1 | +(* TEST |
| 2 | + flags += "-extension-universe alpha"; |
| 3 | + expect; |
| 4 | +*) |
| 5 | + |
| 6 | +(* CR uniqueness: More tests to consider adding here: |
| 7 | + - overwriting tuples |
| 8 | + - overwriting labeled tuples |
| 9 | + - overwriting labeled tuples where only some labels are given |
| 10 | + - overwriting tuples (and labeled ones) with the new .. syntax |
| 11 | + - overwriting inline records (binding a variable to the whole constructor application, |
| 12 | + like | (K { ... }) as v -> ...) |
| 13 | + - overwriting inline records (binding a variable just to the inline record, |
| 14 | + like | K r -> ...) |
| 15 | + - overwriting constructor fields |
| 16 | + - overwriting mutable fields (yes, this is a bit silly, but we should test it) |
| 17 | + - overwriting immutable fields of records with mutable fields |
| 18 | + - local variants of (some of) the above |
| 19 | + - overwriting into a local record with a freshly-constructed bit of memory |
| 20 | + (to make sure that inference does not locally allocate the new memory) |
| 21 | +*) |
| 22 | + |
| 23 | +type record_update = { x : string; y : string } |
| 24 | +[%%expect{| |
| 25 | +type record_update = { x : string; y : string; } |
| 26 | +|}] |
| 27 | + |
| 28 | + |
| 29 | +let update (unique_ r : record_update) = |
| 30 | + let x = overwrite_ r with { x = "foo" } |
| 31 | + in x.x |
| 32 | +[%%expect{| |
| 33 | +Line 2, characters 10-41: |
| 34 | +2 | let x = overwrite_ r with { x = "foo" } |
| 35 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 36 | +Alert : Overwrite not implemented. |
| 37 | +Uncaught exception: File "parsing/location.ml", line 1107, characters 2-8: Assertion failed |
| 38 | + |
| 39 | +|}] |
| 40 | + |
| 41 | +let update2 = update { x = "bar" } |
| 42 | +[%%expect{| |
| 43 | +Line 1, characters 14-20: |
| 44 | +1 | let update2 = update { x = "bar" } |
| 45 | + ^^^^^^ |
| 46 | +Error: Unbound value "update" |
| 47 | +|}] |
| 48 | + |
| 49 | +(* Only global values may be written during overwrites, |
| 50 | + since the GC does not allow heap-to-stack pointers. |
| 51 | + However, it is fine if there are local values (like y here) |
| 52 | + that are not overwritten. We test 2^3 configurations: |
| 53 | + - the overwritten value can be local/global |
| 54 | + - the resulting value can be local/global |
| 55 | + - the value written in the record can be local/global *) |
| 56 | + |
| 57 | +let gc_soundness_bug (local_ unique_ r) (local_ x) = |
| 58 | + exclave_ overwrite_ r with { x } |
| 59 | +[%%expect{| |
| 60 | +Line 2, characters 11-34: |
| 61 | +2 | exclave_ overwrite_ r with { x } |
| 62 | + ^^^^^^^^^^^^^^^^^^^^^^^ |
| 63 | +Alert : Overwrite not implemented. |
| 64 | +Uncaught exception: File "parsing/location.ml", line 1107, characters 2-8: Assertion failed |
| 65 | + |
| 66 | +|}] |
| 67 | + |
| 68 | +let disallowed_by_locality (local_ unique_ r) (local_ x) = |
| 69 | + overwrite_ r with { x } |
| 70 | +[%%expect{| |
| 71 | +Line 2, characters 2-25: |
| 72 | +2 | overwrite_ r with { x } |
| 73 | + ^^^^^^^^^^^^^^^^^^^^^^^ |
| 74 | +Alert : Overwrite not implemented. |
| 75 | +Uncaught exception: File "parsing/location.ml", line 1107, characters 2-8: Assertion failed |
| 76 | + |
| 77 | +|}] |
| 78 | + |
| 79 | +let gc_soundness_bug (unique_ r) (local_ x) = |
| 80 | + exclave_ overwrite_ r with { x } |
| 81 | +[%%expect{| |
| 82 | +Line 2, characters 11-34: |
| 83 | +2 | exclave_ overwrite_ r with { x } |
| 84 | + ^^^^^^^^^^^^^^^^^^^^^^^ |
| 85 | +Alert : Overwrite not implemented. |
| 86 | +Uncaught exception: File "parsing/location.ml", line 1107, characters 2-8: Assertion failed |
| 87 | + |
| 88 | +|}] |
| 89 | + |
| 90 | +let disallowed_by_locality (unique_ r) (local_ x) = |
| 91 | + overwrite_ r with { x } |
| 92 | +[%%expect{| |
| 93 | +Line 2, characters 2-25: |
| 94 | +2 | overwrite_ r with { x } |
| 95 | + ^^^^^^^^^^^^^^^^^^^^^^^ |
| 96 | +Alert : Overwrite not implemented. |
| 97 | +Uncaught exception: File "parsing/location.ml", line 1107, characters 2-8: Assertion failed |
| 98 | + |
| 99 | +|}] |
| 100 | + |
| 101 | +let gc_soundness_no_bug (local_ unique_ r) x = |
| 102 | + exclave_ overwrite_ r with { x } |
| 103 | +[%%expect{| |
| 104 | +Line 2, characters 11-34: |
| 105 | +2 | exclave_ overwrite_ r with { x } |
| 106 | + ^^^^^^^^^^^^^^^^^^^^^^^ |
| 107 | +Alert : Overwrite not implemented. |
| 108 | +Uncaught exception: File "parsing/location.ml", line 1107, characters 2-8: Assertion failed |
| 109 | + |
| 110 | +|}] |
| 111 | + |
| 112 | +let disallowed_by_locality (local_ unique_ r) x = |
| 113 | + overwrite_ r with { x } |
| 114 | +[%%expect{| |
| 115 | +Line 2, characters 2-25: |
| 116 | +2 | overwrite_ r with { x } |
| 117 | + ^^^^^^^^^^^^^^^^^^^^^^^ |
| 118 | +Alert : Overwrite not implemented. |
| 119 | +Uncaught exception: File "parsing/location.ml", line 1107, characters 2-8: Assertion failed |
| 120 | + |
| 121 | +|}] |
| 122 | + |
| 123 | +let gc_soundness_no_bug (unique_ r) x = |
| 124 | + exclave_ overwrite_ r with { x } |
| 125 | +[%%expect{| |
| 126 | +Line 2, characters 11-34: |
| 127 | +2 | exclave_ overwrite_ r with { x } |
| 128 | + ^^^^^^^^^^^^^^^^^^^^^^^ |
| 129 | +Alert : Overwrite not implemented. |
| 130 | +Uncaught exception: File "parsing/location.ml", line 1107, characters 2-8: Assertion failed |
| 131 | + |
| 132 | +|}] |
| 133 | + |
| 134 | +let gc_soundness_no_bug (unique_ r) x = |
| 135 | + overwrite_ r with { x } |
| 136 | +[%%expect{| |
| 137 | +Line 2, characters 2-25: |
| 138 | +2 | overwrite_ r with { x } |
| 139 | + ^^^^^^^^^^^^^^^^^^^^^^^ |
| 140 | +Alert : Overwrite not implemented. |
| 141 | +Uncaught exception: File "parsing/location.ml", line 1107, characters 2-8: Assertion failed |
| 142 | + |
| 143 | +|}] |
0 commit comments