Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spell-check unbound identifiers #4438

Closed
vicuna opened this issue Nov 2, 2007 · 4 comments
Closed

Spell-check unbound identifiers #4438

vicuna opened this issue Nov 2, 2007 · 4 comments

Comments

@vicuna
Copy link

vicuna commented Nov 2, 2007

Original bug ID: 4438
Reporter: thelema
Status: closed (set by @gasche on 2013-07-28T19:27:51Z)
Resolution: fixed
Priority: normal
Severity: feature
Version: 3.10.0
Category: ~DO NOT USE (was: OCaml general)
Monitored by: mehdi @ygrek ertai @yakobowski

Bug description

I have modified my copy of ocaml to report more information on failure to locate an identifier. It searches through the tree of currently bound identifiers for identifiers that could have been intended (looking for a single insertion, deletion, transposition or error). The first one of these is printed out as part of the error message, as follows:

File "coml.ml", line 468, characters 19-23:
Unbound value acts, possible misspelling of act

Additional information

Patch applies to 3.10.0 source tree.

File attachments

@vicuna
Copy link
Author

vicuna commented Nov 10, 2007

Comment author: @xavierleroy

It's a cool hack, but I'm not sure this has its place in a compiler -- looks more like a job for a programming environment. I'll leave this as a feature wish.

@vicuna
Copy link
Author

vicuna commented Nov 13, 2007

Comment author: thelema

I got the idea from a compiler I regard as having the best error messages: GNAT. This feature has saved me plenty of work tracking down correct spellings. I admit that it could also be implemented in an IDE, but it'd become much more hackish there, with having to keep track of scope and namespaces, unless the compiler were (too) strongly integrated into the IDE (like Eclipse).

@vicuna
Copy link
Author

vicuna commented Nov 16, 2007

Comment author: thelema

Additional patch piece that fixes an uncaught exception in the toplevel when dealing with values in modules.

diff --git a/toplevel/genprintval.ml b/toplevel/genprintval.ml
index a0d88ef..b006abb 100644
--- a/toplevel/genprintval.ml
+++ b/toplevel/genprintval.ml
@@ -148,7 +148,7 @@ module Make(O : OBJ)(EVP : EVALPATH with type value = O.t) = struct
match (lookup_fun (Lident name) env).desc with
| Tconstr(ty_path', _, _) -> Path.same ty_path ty_path'
| _ -> false

  •         with Not_found -> false
    
  •         with Not_found | Ident.Found_nearly _ -> false
         then Oide_ident name
         else Oide_dot (Printtyp.tree_of_path p, name)
     | Papply(p1, p2) ->
    

@vicuna
Copy link
Author

vicuna commented Jul 28, 2013

Comment author: @gasche

I independently proposed the exact same feature, with a rather similar implementation (but using a generic edit distance test with a cutoff of 3 instead of a specialized implementation), in #5768. I suppose people where more ready to the idea at this later time, so the feature got more support and was eventually integrated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant