Unhelpful behavior of malformed defform
Nobody has claimed this yet.
- Dominant language
- Racket
- Stars
- 250
- Forks
- 102
- Avg merge
- 11d 11h
- Merged PRs (30d)
- 1
Description
Code:
@defform[(m) #:contracts ([x any/c] [y any/c bad])]
Result:
issue.scrbl:3:27: x: unbound identifier
in: x
When the #:contracts clause is even slightly malformed, it treats the entire expression as part of "pre-flow". This creates very unhelpful error messages. The likely fix is to stop backtracking when the keyword is matched.
As an amusing aside, the following almost-well-formed invocation:
@defform[(m) #:contracts ([const any/c] [thunk procedure? = void])]
Gives the following error:
application: procedure does not accept keyword arguments
procedure: list
arguments...:
#:contracts any/c
Context:
/home/milo/.racket/7.0.0.1/pkgs/scribble-lib/scribble/private/manual-form.rkt:325:0 *defforms
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in scribble/private/manual-form.rkt around line 325, where the defforms procedure appears in the error context, and reproduce the two malformed #:contracts examples from the issue. Trace how the #:contracts keyword is parsed and how malformed input falls back to pre-flow; done means these cases produce useful errors instead of unbound-identifier or keyword-argument failures.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100