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

one type annotation in let means all other definitions must have type annotation #326

Open
shmish111 opened this issue Apr 26, 2020 · 3 comments

Comments

@shmish111
Copy link
Contributor

If possible, please include complete self contained source files (for example by uploading to https://gist.github.com) that exhibit the issue in addition to quoting from them here. The smaller the example the better!

Steps to Reproduce

Check

f : a -> b
f a' =
    let x : a
        x = a'
        y = 1
    in ?xyz

g : a -> b
g a' =
    let x : a
        x = a'
        y : Int
        y = 1
    in ?xyz

Expected Behavior

Type checks fine

Observed Behavior

Errors (1)
Test.idr:217:9
While processing right hand side of f at Test.idr:214:1--220:1:
No type declaration for Test.y

It can be 'fixed' by having a separate let block for things with type annotations and things without. If this is expected behaviour then:

  1. I couldn't find any documentation about it
  2. I found it very unintuitive. Indeed it took me a while to work out that I could have an additional block with the unannotated items
@gallais
Copy link
Collaborator

gallais commented Apr 26, 2020

This bit of the parser is responsible: once we have seen let we commit to
either a block of let-binders or a block of local definitions. We could instead
allow interleavings of the two.
https://github.com/edwinb/Idris2/blob/19426ecd141f93c34268a53ed09b5e48e64ba73b/src/Idris/Parser.idr#L553-L570

@edwinb
Copy link
Owner

edwinb commented Apr 27, 2020

I think it's reasonable to allow interleavings of the two different let forms.

@gallais
Copy link
Collaborator

gallais commented Apr 27, 2020

Fighting the type errors but I have good hope I'll have something soon.

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