Skip to content

Comb layout annotation is sometimes ignored

If I have the following declaration (in Ocaml dialect):

type parameter =
  [@layout:comb]
    B of nat
  | C of int
  | D of string
  | A of unit

then I get constructors sorted and balanced in the final Michelson representation as if layout annotation was not there:

(or (or (unit %a) (nat %b)) (or (int %c) (string %d)))

However, if I add the bar symbol before the first constructor, then everything works as expected:

type parameter =
  [@layout:comb]
  | B of nat
  | C of int
  | D of string
  | A of unit

This results in

(or (nat %b) (or (int %c) (or (string %d) (unit %a))))

This behavior is pretty confusing, at first I thought that it is not possible to get constructors compiled in the specified order.

Edited by Konstantin Ivanov