Conversation
904a970 to
b911893
Compare
| if is_recursive then new_env | ||
| else if not is_recursive then begin | ||
| (* add ghost bindings to help detecting missing "rec" keywords *) | ||
| else if not is_recursive && List.for_all sexp_is_fun spat_sexp_list |
There was a problem hiding this comment.
Do we want List.for_all or List.exists? I would be content with a let .. and .., one of them being a function.
There was a problem hiding this comment.
I do not have a strong opinion either way. I guess it should be relatively safe to use List.exists since let .. and .. is rarely used to define something else than recursive functions.
| let value2 = value2 (* typo: should be value1 *) + 1 in | ||
| ^^^^^^ | ||
| Error: Unbound value value2 | ||
| Hint: Did you mean value1? |
There was a problem hiding this comment.
At this point in the patch series, there is no heuristic to disable the missing-rec handling for non-functions (added in the next commit 92ff83e ). How come there is no recursive-definition here, does the spellchecking hint override it naturally?
There was a problem hiding this comment.
No, it appears I just messed up the tests while rebasing. This should be fixed now.
b911893 to
457da87
Compare
|
This looks good to merge in |
typing/typetexp.ml
Outdated
| let (_, line, _) = Location.get_pos_info loc.Location.loc_start in | ||
| fprintf ppf | ||
| "@.@[%s %i@]" | ||
| "Hint: If this is a recursive definition, you should add a 'rec' keyword on line" |
There was a problem hiding this comment.
This line seems to be a bit long, and the resulting
user-facing message is larger than what is usually
output by the Format module. It might be worthwhile
to both split the line and insert a breakable space.
There was a problem hiding this comment.
See also Format.pp_print_text : formatter -> string -> unit which turns all spaces into breakable spaces; here it could be used by turning %s into%a.
There was a problem hiding this comment.
(Actually, I am not certain we want to blindly turn all spaces
into breakable ones. Given the shape of the message, there
is a possibility that the break would occur right before the line
number, which is not very nice.)
There was a problem hiding this comment.
Well this particular space is not part of the string literal so it actually wouldn't be made breakable.
There was a problem hiding this comment.
Also, I am wondering if it would be possible to avoid "@." by opening a vectical box :
fprintf ppf
"@[<v>@[Unbound value %a@]" longident lid;
spellcheck ppf fold_values env lid;
let (_, line, _) = Location.get_pos_info loc.Location.loc_start in
fprintf ppf
"@,@[%s %i@]@]"
"Hint: If this is a recursive definition, you should add a 'rec' keyword on line"since the behavior of @. tends to mask problems with the formatting.
There was a problem hiding this comment.
@gasche sure, but we can get a break before the word "line";
in the surrounding code, breakable spaces are explicitly placed
at strategic points.
|
Another thing we could do is disable the hint if the let-binding is "ghost" code -- automatically generated. |
831e7a4 to
1e0e6f0
Compare
7e8b309 to
3d0f0fa
Compare
|
I just noticed a small inconsistency in the comments: (I am quite probably the one to blame for introducing |
3d0f0fa to
61528b9
Compare
|
Good catch, thanks. |
|
Anything else I can do about this PR? |
|
@xclerc, @mshinwell, @lpw25: is there a better way to know if your concerns with the previous version are addressed in this new PR than to merge in trunk and let you see for yourself over time? |
|
Even if the conditions triggering the warning need to be |
|
@Armael could you move the Changes entry to be in the development version rather than 4.07? |
61528b9 to
465a5f7
Compare
This reverts commit 90fbe53 except for the Changes entry.
Imported from Xavier Clerc patch in ocaml#1678
465a5f7 to
acfd378
Compare
|
@gasche done and rebased on trunk |
This is a second iteration of #1472, following up on #1678 . Compared to the first iteration, this additionally includes:
fold_valuesused by the spellchecking hint, proposed by @xclerc in Do not trigger the "missing rec" hint for simple values #1678;