File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
testsuite/tests/typing-local Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -487,6 +487,27 @@ Line 3, characters 63-64:
487
487
Error: The value a is local, so cannot be used inside a closure that might escape
488
488
|}]
489
489
490
+ (* Regression test for bug with mishandled regional function modes *)
491
+ let bug4 : local_ (string -> foo:string -> unit) -> (string -> unit) =
492
+ fun f -> f ~foo:"hello"
493
+ [%%expect{|
494
+ Line 2, characters 11-25:
495
+ 2 | fun f -> f ~foo:"hello"
496
+ ^^^^^^^^^^^^^^
497
+ Error: This value escapes its region
498
+ |}]
499
+
500
+ let bug4' () =
501
+ let local_ f arg ~foo = () in
502
+ let local_ perm ~foo = f ~foo in
503
+ perm ~foo:"foo" "Optional"
504
+ [%%expect{|
505
+ Line 3, characters 25-31:
506
+ 3 | let local_ perm ~foo = f ~foo in
507
+ ^^^^^^
508
+ Error: This local value escapes its region
509
+ Hint: Cannot return local value without an explicit "local_" annotation
510
+ |}]
490
511
491
512
(*
492
513
* Optional arguments
Original file line number Diff line number Diff line change @@ -5396,7 +5396,7 @@ and type_application env app_loc expected_mode position funct funct_mode sargs =
5396
5396
in
5397
5397
let ty_ret, mode_ret, args =
5398
5398
collect_apply_args env funct ignore_labels ty (instance ty)
5399
- (Value_mode. regional_to_global_alloc funct_mode) sargs
5399
+ (Value_mode. regional_to_local_alloc funct_mode) sargs
5400
5400
in
5401
5401
let partial_app = is_partial_apply args in
5402
5402
let position = if partial_app then Default else position in
You can’t perform that action at this time.
0 commit comments