The type of the equality operator that’s open in Base is int -> int -> bool, whereas core and the standard library by default use the polymorphic equality operator of type 'a -> 'a -> bool.
Instead of lexbuf.last_char = Some cr use Option.equal Int.equal lexbuf.last_char (Some cr).
It’s because the polymorphic operators often do not correspond to what users expect, since they check for equality of the runtime structure of the values. They also throw runtime errors if users try to compare functions for equality.