yesodweb / yesodweb/persistent
Better error message for dealing with bad constructors
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 486
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
config/models
Test field Text.
Error:
Model.hs:13:7:
Illegal type constructor or class name: ‘Text.’
and it goes on with a huge dump of TH splices.
In practice, it's unlikely any user will actually face this unless they accidentally typo, but it's good practice to give good error messages.
The fix is as follows:
In persistent, Database.Persist.Quasi, Lines 67-69,
getCon t =
case T.breakOnEnd "." t of
(_, "") -> FTTypeCon Nothing t
should be
getCon t =
case T.breakOnEnd "." t of
(t', "") -> error ("Invalid data constructor - dangling qualifier: " ++ T.unpack t')
Since this is harmless, maybe it can be snuck in a code refactor commit in the future?
Contributor guide
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
Run the reproducer in config/models and inspect Database.Persist.Quasi around lines 67-69; Model.hs:13:7 shows the current compiler error and TH dump. Done means dangling-qualified constructors produce the specified invalid-data-constructor message instead of the existing error output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100