racket / racket/scribble

Unhelpful behavior of malformed defform

Open
#178 0 comments 1 reaction 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.