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

Parse error: Illegal token: where #883

Closed
k-bx opened this issue Sep 17, 2015 · 10 comments
Closed

Parse error: Illegal token: where #883

k-bx opened this issue Sep 17, 2015 · 10 comments

Comments

@k-bx
Copy link
Contributor

k-bx commented Sep 17, 2015

For this code:

main :: IO ()
main = do
    putStrLn "Hello, world"
  where
    foo = undefined

If I press "enter" while having a cursor at the end of a where word, I see an error no catch for tag: parse-error, "Illegal token: where"

(bug was updated with a simpler use-case)

@gracjan
Copy link
Contributor

gracjan commented Sep 17, 2015 via email

@k-bx
Copy link
Contributor Author

k-bx commented Sep 17, 2015

@gracjan sure, will try to do that (after I fill another bug-report, hehe)

@gracjan
Copy link
Contributor

gracjan commented Sep 17, 2015

Sufficient test suite is a prerequisite to actually fix the indentation problems once and for all.

@k-bx
Copy link
Contributor Author

k-bx commented Sep 17, 2015

@gracjan can't agree more :) sorry for silly question: is there an info where tests are and how do I run them? Couldn't find on wiki.

@gracjan
Copy link
Contributor

gracjan commented Sep 17, 2015

Hmm,

Tests are in 'tests' directory, specifically 'tests/haskell-indentation-tests.el'. You run them using:

make check

or

make check EMACS=/path/to/emacs

@k-bx
Copy link
Contributor Author

k-bx commented Sep 17, 2015

Ok, added a PR with a test-case

@ivan-m
Copy link
Contributor

ivan-m commented Sep 22, 2015

I've just been bitten by this as well, but if I remove the do then it works.

@ivan-m
Copy link
Contributor

ivan-m commented Sep 23, 2015

I think part of it is how much the where is indented by: I'm using this on an existing code base in literate Haskell, where the previous programmer liked to only indent where by 1 space and then the contents of the where block by 1 space; if I re-indent it to be 2 spaces for both cases then it works.

(Another thing that works is to remove a bird track after the where so that the contents of the block are in a separate literate block, but that doesn't really solve the problem.)

@gracjan
Copy link
Contributor

gracjan commented Sep 30, 2015

Interestingly, when indenting the where itself in code like:

main = do
  putStrLn "Hello, world"
    where    

it offers two indentation positions, but when one space is added before putStrLn then only one indentation position is offerred:

main = do
   putStrLn "Hello, world"
     where    

It seems there are more bugs around the where clause handling.

@gracjan
Copy link
Contributor

gracjan commented Sep 30, 2015

@k-bx: thanks for the test, that really helped.

Can somebody use their eyes on the fix?

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

3 participants