Code segfaulting in bytecode compiler but running in native compiler

I was able to reproduce in 4.10.1 with the following code, but it crashes only if I invoke it via ocaml foo.ml, it works fine if the code is typed into the toplevel.

let x =
  object
    method f = ""
  end

let _ =
  (object method f = x#f end)#f