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

Error: Unsolved holes: when using _ in do block #1887

Closed
alexhumphreys opened this issue Aug 31, 2021 · 1 comment · Fixed by #1889
Closed

Error: Unsolved holes: when using _ in do block #1887

alexhumphreys opened this issue Aug 31, 2021 · 1 comment · Fixed by #1889

Comments

@alexhumphreys
Copy link
Contributor

alexhumphreys commented Aug 31, 2021

Steps to Reproduce

Found on Idris 2, version 0.4.0-70ac0f410. Requires idris2 -p contrib:

module Foo

import Text.Parser

infixOp1 : Grammar state t True ()
        -> a
        -> Grammar state t True a
infixOp1 p x = do
  p -- compiles
  pure x

infixOp2 : Grammar state t True ()
        -> a
        -> Grammar state t True a
infixOp2 p x = do
  y <- p -- compiles
  pure x

infixOp3 : Grammar state t True ()
        -> a
        -> Grammar state t True a
infixOp3 p x = do
  _ <- p -- Error: Unsolved holes
  pure x

Expected Behavior

I would expect all three to compile, assuming I understood #1095 and it's ok to throw away unit types as is the case of p in infixOp1.

Observed Behavior

infixOp1 and infixOp2 compile, infixOp3 throws the following error:

"Idrall/Foo.idr" 24L, 439C written
Error: Unsolved holes:
Idrall.Foo.{c2:805} introduced at:
Idrall.Foo:23:3--23:9
 19 | infixOp3 : Grammar state t True ()
 20 |         -> a
 21 |         -> Grammar state t True a
 22 | infixOp3 p x = do
 23 |   _ <- p -- Error: Unsolved holes
        ^^^^^^
Idrall.Foo.{tok:828} introduced at:
Idrall.Foo:24:3--24:9
 20 |         -> a
 21 |         -> Grammar state t True a
 22 | infixOp3 p x = do
 23 |   _ <- p -- Error: Unsolved holes
 24 |   pure x
        ^^^^^^
Idrall.Foo.{state:829} introduced at:
Idrall.Foo:24:3--24:9
 20 |         -> a
 21 |         -> Grammar state t True a
 22 | infixOp3 p x = do
 23 |   _ <- p -- Error: Unsolved holes
 24 |   pure x
        ^^^^^^

I'm not sure why it's ok when bound to a name, but fails when bound to _. Maybe I'm doing something wrong, but at least the error message is pretty confusing...

This is a small example, but I ran into this in the wild here

@gallais
Copy link
Member

gallais commented Aug 31, 2021

_ is not detected as a valid variable name and so _ <- p is desugared as a pattern-matching bind.
Which means it introduces a case and then Idris has a hard time guessing what the value of the boolean
stating whether the grammar is productive should be.

gallais added a commit to gallais/Idris2 that referenced this issue Aug 31, 2021
@gallais gallais linked a pull request Aug 31, 2021 that will close this issue
andrevidela pushed a commit to andrevidela/Idris2 that referenced this issue Oct 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants