Skip to content

Evaluation order: ocamlc-ocamlopt difference on method calls #13641

Open
@jmadiot

Description

Contrary to what might be expected, though the order is not specified, in the expression e1 #m e2, native-code compilation evaluates e1 before e2 but bytecode evaluates e2 before e1. For example with

let () = (print_string "A"; object method m () = () end)#m (print_string "B")
class c () = object method m () = () end
let () = (new c (print_string "C"))#m (print_string "D")

ocamlopt prints ABCD, ocamlc prints BADC, with versions 4.02 to 5.2 on my machine.

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions