Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ask user to add exclave_ instead of local_ #1853

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions ocaml/testsuite/tests/typing-local/local.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Line 3, characters 2-3:
3 | r
^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
|}]

external idint : local_ int -> int = "%identity"
Expand Down Expand Up @@ -40,7 +40,7 @@ Line 3, characters 2-3:
3 | r
^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
|}]

let leak n =
Expand All @@ -51,7 +51,7 @@ Line 3, characters 2-3:
3 | r
^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
|}]

let leak n =
Expand All @@ -62,7 +62,7 @@ Line 3, characters 2-3:
3 | f
^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
|}]

let leak n =
Expand All @@ -73,7 +73,7 @@ Line 3, characters 2-3:
3 | f
^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
|}]

(* If both type and mode are wrong, complain about type *)
Expand Down Expand Up @@ -268,7 +268,7 @@ Line 1, characters 15-21:
1 | let apply2 x = f4 x x
^^^^^^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
Hint: This is a partial application
Adding 2 more arguments will make the value non-local
|}]
Expand All @@ -278,7 +278,7 @@ Line 1, characters 15-23:
1 | let apply3 x = f4 x x x
^^^^^^^^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
Hint: This is a partial application
Adding 1 more argument will make the value non-local
|}]
Expand Down Expand Up @@ -316,7 +316,7 @@ Line 1, characters 15-18:
1 | let apply1 x = g x
^^^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
Hint: This is a partial application
Adding 1 more argument will make the value non-local
|}]
Expand All @@ -339,7 +339,7 @@ Line 1, characters 23-32:
1 | let apply3_wrapped x = (g x x) x
^^^^^^^^^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
Hint: This is a partial application
Adding 1 more argument will make the value non-local
|}]
Expand Down Expand Up @@ -476,7 +476,7 @@ Line 1, characters 52-65:
1 | let app4' (f : b:local_ int ref -> a:int -> unit) = f ~b:(ref 42)
^^^^^^^^^^^^^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
Hint: This is a partial application
Adding 1 more argument will make the value non-local
|}]
Expand Down Expand Up @@ -531,7 +531,7 @@ Line 1, characters 50-59:
1 | let rapp3 (f : a:int -> unit -> local_ int ref) = f ~a:1 ()
^^^^^^^^^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
|}]

let bug1 () =
Expand All @@ -546,7 +546,7 @@ Line 7, characters 2-5:
7 | res
^^^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
|}]
let bug2 () =
let foo : a:local_ string -> (b:local_ string -> (c:int -> unit)) =
Expand Down Expand Up @@ -655,7 +655,7 @@ Line 3, characters 25-31:
3 | let local_ perm ~foo = f ~foo in
^^^^^^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
Hint: This is a partial application
Adding 1 more argument may make the value non-local
|}]
Expand All @@ -677,7 +677,7 @@ Line 3, characters 2-5:
3 | res
^^^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
|}]

(* In principle. it would be sound to allow this one:
Expand All @@ -690,7 +690,7 @@ Line 3, characters 2-5:
3 | res
^^^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
|}]

let optret1 (f : ?x:int -> local_ (y:unit -> unit -> int)) = f ()
Expand All @@ -699,7 +699,7 @@ Line 1, characters 61-65:
1 | let optret1 (f : ?x:int -> local_ (y:unit -> unit -> int)) = f ()
^^^^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
Hint: This is a partial application
Adding 1 more argument will make the value non-local
|}]
Expand Down Expand Up @@ -1334,7 +1334,7 @@ Line 3, characters 2-3:
3 | r
^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
|}]

let foo x =
Expand Down Expand Up @@ -1488,7 +1488,7 @@ Line 3, characters 2-7:
3 | x.imm
^^^^^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
|}]
let foo (local_ x) = x.mut
[%%expect{|
Expand Down Expand Up @@ -1523,7 +1523,7 @@ Line 3, characters 2-5:
3 | imm
^^^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
|}]
let foo (local_ { mut }) = mut
[%%expect{|
Expand Down Expand Up @@ -2494,7 +2494,7 @@ Line 4, characters 20-22:
4 | | GFoo (_, s') -> s'
^^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
|}]

(* and regional gives regional *)
Expand Down Expand Up @@ -2558,7 +2558,7 @@ Line 3, characters 14-16:
3 | | [:s':] -> s'
^^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
|}]

let f (local_ a : string iarray) =
Expand Down Expand Up @@ -2625,7 +2625,7 @@ Line 11, characters 13-59:
11 | let f () = fold_until [] ~init:0 ~f:(fun _ _ -> Right ())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This local value escapes its region
Hint: Cannot return local value without an explicit "local_" annotation
Hint: Cannot return local value without an "exclave_" annotation
Hint: This is a partial application
Adding 1 more argument will make the value non-local
|}]
Expand Down
4 changes: 2 additions & 2 deletions ocaml/typing/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8370,8 +8370,8 @@ let escaping_hint failure_reason submode_reason
begin match failure_reason, context with
| `Locality, Some Return ->
[ Location.msg
"@[Hint: Cannot return local value without an explicit@ \
\"local_\" annotation@]" ]
"@[Hint: Cannot return local value without an@ \
\"exclave_\" annotation@]" ]
| `Locality, Some Tailcall_argument ->
[ Location.msg
"@[Hint: This argument cannot be local, because this is a tail call@]" ]
Expand Down
Loading