helpful:   suggests a closest variable name on unbound identifier error.
1 Examples
2 Limitations
3 API
#%top
8.6

helpful: suggests a closest variable name on unbound identifier error.

Sorawee Porncharoenwase <sorawee.pwase@gmail.com>

 (require helpful) package: helpful

This module provides an ability to suggest a closest variable name on unbound identifier error. Simply use (require helpful) where you want this feature.

The definition of “closest” is according to the Levenshtein distance.

1 Examples

; Suggestion for a module binding
> (module test racket
    (require helpful)
    (define (fact x)
      (cond
        [(zero? x) 1]
        [else (* x (fac (sub1 x)))])))

eval:1:0: fac: unbound identifier

  in: fac

  suggestion: do you mean `fact'?

; Suggestion for a local binding
> (module test racket
    (require helpful)
    (define (fact x)
      (cond
        [(zero? x) 1]
        [else (* x (fact (sub1 y)))])))

eval:2:0: y: unbound identifier

  in: y

  suggestion: do you mean `x'?

; Suggestion for an imported identifier
> (module test racket
    (require helpful)
    (defun (fact) 1))

eval:3:0: defun: unbound identifier

  in: defun

  suggestion: do you mean `define'?

; No suggestion outside a module or #lang
> (require helpful)
> (let ([x 1]) y)

y: undefined;

 cannot reference an identifier before its definition

  in module: top-level

2 Limitations

The feature only affects code in a module or a #lang. Because top level is hopeless, the feature is disabled for the REPL.

The feature only works reliably for code at phase level 0.

3 API

syntax

(#%top . x)

Does what’s described above.