Dumb error: Unbound value bump_dir_of_sexp

Yes, this error is very stupid. I’ve been staring it for 15+ minutes and can not figure out what is wrong.

  1. The error itself:
113 |   type t = Bump of bump_dir | Toggle_collapse [@@deriving sexp]
                         ^^^^^^^^
Error: Unbound value bump_dir_of_sexp
  1. So now we ask: is sexp derived on bump_dir ? We put cursor over bump_dir, hit goto def, and get:
type bump_dir = Incr | Decr [@@deriivng sexp]
  1. Okay, is there another bump_dir in the project? (a) according to rg, no: (b) this was also the one that merlin/lsp jumped to

  2. Well, is bump_dir in scope ?

  3. I modify the code to:

  let _x: bump_dir = Incr;;

  type t = Bump of bump_dir | Toggle_collapse [@@deriving sexp]

Note here, the _x line does not get an error; the error is still unbound value bump_dir_of_sexp.

  1. Maybe this is a caching issue? rm -rf _build; dune build-w – still same error.

At this point I’m confused – what is there left for me to try?

I don’t know if it’s in your code, but at least in the code you pasted, there is a typo in the “deriivng” attribute of bump_dir

2 Likes
  1. That fixed it.

  2. This “silent failure” behaviour confuses me; I’m surprised there was no compiler error for mis-spelling @@deriving.

The compiler doesn’t know that this attribute exists. Attributes are extensions points for the syntax tree. Maybe the ppx itself could look for mispellings ?

1 Like

Thanks; explanation makes sense; I’ll have to remember to check spelling in the future.