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

If in do issues #386

Closed
garyb opened this issue Apr 22, 2014 · 3 comments
Closed

If in do issues #386

garyb opened this issue Apr 22, 2014 · 3 comments

Comments

@garyb
Copy link
Member

garyb commented Apr 22, 2014

The impossible happened in desugarDo:

test = do 
  if true 
  then return true 
  else return false

Let statement cannot be the last statement in a do block:

test = do 
  let x = 1
  if true 
  then return true 
  else return false
@garyb garyb added bug labels Apr 22, 2014
@paf31 paf31 added this to the 0.5.0 milestone Apr 22, 2014
@paf31
Copy link
Contributor

paf31 commented Apr 22, 2014

Both of these can be fixed by indenting the then and else lines:

test = do 
  if true 
    then return true 
    else return false
test = do 
  let x = 1
  if true 
    then return true 
    else return false

@paf31 paf31 closed this as completed Apr 22, 2014
@michaelficarra
Copy link
Contributor

I've managed to trigger the compiler crash with the same error as @garyb (using 0.6.9.5):

psc: The impossible happened in desugarDo

I believe it was code like this that triggered it:

... $ \a -> do
  if a then do
    ...
  else do
    ...

I fixed the problem by removing that first unnecessary do.

@paf31 paf31 reopened this Jul 4, 2015
@paf31 paf31 modified the milestones: 0.8.0, 0.5.0 Jul 4, 2015
@sharkdp
Copy link
Contributor

sharkdp commented Jul 24, 2015

Possibly related: the same compiler error (the impossible happened..) also appears for empty do blocks. It would be convenient if the compiler would throw a compile error (Error at ...: Empty do block).

@paf31 paf31 closed this as completed in 1f3245f Aug 19, 2015
garyb added a commit that referenced this issue Aug 19, 2015
dunhamsteve pushed a commit to dunhamsteve/purescript that referenced this issue Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants