Trying to add an alert to a regular
let foo = 1 [@@alert hey "there"]
But it has no effect.
One can work around like this (I can’t be held responsible for any eye-rolling or horrified expressions that may follow):
let foo = 1
val foo : int [@@alert hey "there"]
Looking at the docs, it seems that alerts are only for types or signature items. But I wonder if this is a fundamental technical limitation? Or a design decision?
The following seems to work:
let foo [@alert hey "there"] = 1
let x = foo + 1
File "a.ml", line 3, characters 8-11:
3 | let x = foo + 1
Alert hey: foo
But I’m really not sure that it’s what I think it is. I just reduced the number of
@s incrementally until I found one that worked .
Wow! I tried a lot of combinations, but I guess not this one Thanks!
The attributes page has an explanation and some examples of where and how the different incantations of
[@@@ your_attribute_goes_here] apply. Worth checking out!