Quick Summary: Error message on type definition in small case is misleading.
$ elm repl
> type alias s = { a : Int }
-- PARSE ERROR ------------------------------------------------------------- elm
Something went wrong while parsing repl_value_0's definition.
3| repl_value_0 =
4| type alias s = { a : Int }
^
I was expecting to see an expression, like x or 42.
Error message should indicate types must be started with upper-case.
Why is this misleading?
Your previous line still expects "something". That's what the error is saying. It points to the place where it would expect your functions body. Which could be 42 or x.
3| repl_value_0 =
42
4| type alias s = { a : Int }
If I write 's' in capital no error happens:
> type alias S = { a : Int }
But compiler doesn't complain about small or capital letter. That's misleading.
I'm getting the same error on ellie.
https://ellie-app.com/4VshpkZ33GLa1
As the first line is still missing the body
@razzee the repl_value_0 line is not something @yousefvand wrote, it's what expressions are transformed to by the Elm repl.
The issue here is basically that the repl doesn't recognize this as a type alias declaration, so tries to parse it as an expression, leading to a misleading error.
So, to reframe this issue:
Entering type alias a = String on the repl leads to a misleading error.
Thank you for the report @yousefvand! I am working on a bunch of infrastructure improvements, so my development build is currently producing:
---- Elm 0.19.1 ----------------------------------------------------------------
Say :help for help and :exit to exit! More at <https://elm-lang.org/0.19.1/repl>
--------------------------------------------------------------------------------
> type alias s = { a : Int }
|
-- EXPECTING TYPE ALIAS NAME ---------------------------------------------- REPL
I am partway through parsing a type alias, but I got stuck here:
2| type alias s = { a : Int }
^
I was expecting a name like Person or Point next. Just make sure it is a name
that starts with a capital letter!
Note: Here is an example of a valid `type alias` for reference:
type alias Person =
{ name : String
, age : Int
, height : Float
}
This would let us use `Person` as a shorthand for that record type. Using this
shorthand makes type annotations much easier to read, and makes changing code
easier if you decide later that there is more to a person than age and height!
There were some changes in how the REPL works such that it does not miscategorize inputs as often, so now it is actually recognizing that this was meant to be a type alias!
The fix should become available with Elm 0.19.1 along with a bunch of other improvements. Thanks again for reporting this!
Most helpful comment
@razzee the
repl_value_0line is not something @yousefvand wrote, it's what expressions are transformed to by the Elm repl.The issue here is basically that the repl doesn't recognize this as a type alias declaration, so tries to parse it as an expression, leading to a misleading error.
So, to reframe this issue:
Entering
type alias a = Stringon the repl leads to a misleading error.