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

Confusing parser error messages on wrong kind #667

Open
jiribenes opened this issue Nov 5, 2024 · 0 comments
Open

Confusing parser error messages on wrong kind #667

jiribenes opened this issue Nov 5, 2024 · 0 comments
Labels
errormessage feature New feature or request

Comments

@jiribenes
Copy link
Contributor

There are a lot of confusing error messages from the parser when writing things like:

record Fun(f: (Int, Int) => Bool)
//                       ^^
// Expected ) but got =>

def foo { f: (Int, Int) => Bool at {} } = <>
//                         ^^^^
// Expected an interface type.

def bar(f: (Int, Int) => Bool) = <>
//                    ^^
// Expected ) but got =>

They all stem from the fact that we distinguish between computation types and value types in the parser.
Instead, we should parse some generic, kind-less type and only resolve it properly some time later (ideally in Typer?)

My preferred error messages would be something like:

record Fun(f: (Int, Int) => Bool)
//            ~~~~~~~~~~~~~~~~~~
//
// Expected a value type, got a computation type.
// Did you mean: `(Int, Int) => Bool at {}`?

def foo { f: (Int, Int) => Bool at {} } = <>
//            ~~~~~~~~~~~~~~~~~~~~~~~
//
// Expected a computation type, got a value type.
// Did you mean:
// 1. `{ f: (Int, Int) => Bool }`?
// 2. `(f: (Int, Int) => Bool at {})`?

def bar(f: (Int, Int) => Bool) = <>
@jiribenes jiribenes added feature New feature or request errormessage labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
errormessage feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant