File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed
testsuite/tests/typing-local Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -395,6 +395,14 @@ let makeverylong n =
395
395
ignore_local (local_array 100_000 n);
396
396
()
397
397
398
+ let fun_with_optional_arg ?(local_ foo = 5 ) () =
399
+ let _ = foo + 5 in
400
+ ()
401
+
402
+ let optionalarg ((f : ?foo:local_ int -> unit -> unit ), n ) =
403
+ let () = f ~foo: n () in
404
+ ()
405
+
398
406
let run name f x =
399
407
let prebefore = Gc. allocated_bytes () in
400
408
let before = Gc. allocated_bytes () in
@@ -446,7 +454,8 @@ let () =
446
454
run " stringbint" readstringbint () ;
447
455
run " bigstringbint" readbigstringbint () ;
448
456
run " verylong" makeverylong 42 ;
449
- run " manylong" makemanylong 100
457
+ run " manylong" makemanylong 100 ;
458
+ run " optionalarg" optionalarg (fun_with_optional_arg, 10 )
450
459
451
460
452
461
(* In debug mode, Gc.minor () checks for minor heap->local pointers *)
Original file line number Diff line number Diff line change 31
31
bigstringbint: OK
32
32
verylong: OK
33
33
manylong: OK
34
+ optionalarg: OK
Original file line number Diff line number Diff line change @@ -362,9 +362,12 @@ let register_allocation_mode alloc_mode =
362
362
| Amode _const -> ()
363
363
| Amodevar _ -> allocations := alloc_mode :: ! allocations
364
364
365
- let register_allocation ( expected_mode : expected_mode ) =
365
+ let register_allocation_value_mode mode =
366
366
register_allocation_mode
367
- (Value_mode. regional_to_global_alloc expected_mode.mode)
367
+ (Value_mode. regional_to_global_alloc mode)
368
+
369
+ let register_allocation (expected_mode : expected_mode ) =
370
+ register_allocation_value_mode expected_mode.mode
368
371
369
372
let optimise_allocations () =
370
373
if Clflags.Extension. is_enabled Local then begin
@@ -433,6 +436,7 @@ let option_none env ty mode loc =
433
436
mkexp (Texp_construct (mknoloc lid, cnone, [] )) ty mode loc env
434
437
435
438
let option_some env texp mode =
439
+ register_allocation_value_mode mode;
436
440
let lid = Longident. Lident " Some" in
437
441
let csome = Env. find_ident_constructor Predef. ident_some env in
438
442
mkexp ( Texp_construct (mknoloc lid , csome, [texp]) )
You can’t perform that action at this time.
0 commit comments