Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup doesn't work properly / parse error on input 'import' #167

Closed
k-bx opened this issue Jul 3, 2017 · 4 comments
Closed

Setup doesn't work properly / parse error on input 'import' #167

k-bx opened this issue Jul 3, 2017 · 4 comments

Comments

@k-bx
Copy link

k-bx commented Jul 3, 2017

Hi. Not sure if I'm doing something wrong or not. I've created a very small repo where you can reproduce the error https://github.com/k-bx/docbug

The library code is as simple as:

module SomeLib where
-- $setup
-- let x = 1

import Data.Monoid

-- |
-- >>> add 1 1
-- 2
add :: Int -> Int -> Int
add x y = x + y

When I run stack test, I get:

$ stack test
docbug-0.1.0.0: test (suite: doctests)


src/SomeLib.hs:5:1: error: parse error on input ‘import’

Test suite failure for package docbug-0.1.0.0
    doctests:  exited with: ExitFailure 1
Logs printed to console
@sol
Copy link
Owner

sol commented Jul 6, 2017

@k-bx This is a limitation of GHC's parser. The import has to go before the $setup-chunk.

@k-bx
Copy link
Author

k-bx commented Jul 6, 2017

@sol aha. Thank you!

@k-bx k-bx closed this as completed Jul 6, 2017
@kindaro
Copy link
Contributor

kindaro commented Jan 23, 2018

I just stumbled upon this issue. Let us maybe make some appropriate corrections to README so that less people have to rediscover this ticket?

@andreasabel
Copy link
Collaborator

Yes, can you do this?

kindaro added a commit to kindaro/doctest that referenced this issue Jan 23, 2018
andreasabel added a commit that referenced this issue Jan 24, 2018
Add a note to readme concerning issue #167 (setup code cannot be within import statements).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants