Sorawee Porncharoenwase <sorawee.pwase@gmail.com>
This package provides suggestions on unbound identifier error. It requires Racket 8.7 at minimum.
There are two ways to activate the suggestions.
Using raco helpful as a replacement of racket
Adding (require helpful) in a module that you want to get suggestions and running racket normally
Currently, the package provides two kinds of suggestions.
One suggestion is hinting a “closest” identifier name, which could be helpful when the error is caused by a typo mistake. The definition of “closest” is according to the Levenshtein distance. It breaks a tie by the alphabetical order, with module and lexical bindings being prioritized over imported identifiers.
Another suggestion is hinting modules that could be imported to make the identifier bound, which could be helpful when you forgot to import the desired module. This feature consults Scribble and the Racket documentation index and thus is only available if they are installed.
;Suggestion for a module binding(condeval:1:0: fac: unbound identifier
in: fac
suggestion: do you mean `fact'?
;Suggestion for a local binding(condeval:2:0: y: unbound identifier
in: y
suggestion: do you mean `x'?
;Suggestion for an imported identifiereval:3:0: defun: unbound identifier
in: defun
suggestion: do you mean `define'?
;Suggestion for a module to import;(only when Scribble and the Racket documentation index are installed)eval:4:0: ->: unbound identifier
in: ->
suggestion: do you mean `-'?
alternative suggestion: do you want to import one of the
following modules, which provides the identifier?
`lang/htdp-intermediate-lambda'
`lang/htdp-intermediate'
`ffi/unsafe'
`lang/htdp-beginner-abbr'
`mzlib/contract'
`lang/htdp-advanced'
`deinprogramm/sdp/beginner'
`lang/htdp-beginner'
`racket/contract/base' or `racket/contract' or `racket'
`typed/racket/base' or `typed/racket'
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.
syntax
( #%top . x)
y: undefined;
cannot reference an identifier before its definition
in module: top-level
;No suggestion for use-before-definition errorsan-id: undefined;
cannot reference an identifier before its definition
in module: 'test
;Prioritization of module/lexical bindingseval:5:0: add4: unbound identifier
in: add4
suggestion: do you mean `add2'?
;Alphabetical ordereval:6:0: add4: unbound identifier
in: add4
suggestion: do you mean `add2'?
;Consistent with Racketeval:7:0: #%app: missing procedure expression;
probably originally (), which is an illegal empty
application
in: (#%app)
;Also consistent with Racketeval:8:0: add2: unbound identifier
in: add2
suggestion: do you mean `add1'?
;Another module recommendationeval:9:0: format-id: unbound identifier
in: format-id
suggestion: do you mean `format'?
alternative suggestion: do you want to import
`racket/syntax', which provides the identifier?