Skip to content

build_apply messing up the order of side-effects for optional parameters and arguments #10652

@lpw25

Description

@lpw25

I think the following behaviour is incorrect:

# let foo ?a =
    print_endline "a parameter";
    fun ~b ->
    print_endline "b parameter";
    fun ~c ->
    print_endline "c parameter";;
val foo : ?a:'a -> b:'b -> c:'c -> unit = <fun>

# let f = foo ~a:(print_endline "a argument") ~c:(print_endline "c argument");;
c argument
val f : b:'_weak7 -> unit = <fun>

# f ~b:(print_endline "b argument");;
b argument
a argument
a parameter
b parameter
c parameter
- : unit = ()

The first call should perform give:

c argument
a argument
a parameter

and the second should give:

b argument
b parameter
c parameter

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions