on master help sign in
improve error message for bad declaration starts
ef457e7Evan Czaplicki
compiler/src/Reporting/Error/Syntax.hs+14−6
@@ -1407,12 +1407,20 @@ toDeclarationsReport source decl =
1407 Code.toSnippet source region Nothing
1407 Code.toSnippet source region Nothing
1408 (
1408 (
1409 D.reflow $
1409 D.reflow $
1410− "I was expecting to see a new declaration here:"
1410+ "I was expecting to see a declaration, but I am getting stuck here:"
1411 ,
1411 ,
1412 D.stack
1412 D.stack
1413+ [ case Code.whatIsNext source row col of
1414+ Code.Other (Just char) | Char.isUpper char ->
1413− [ D.reflow $
1415+ D.reflow $
1414− "I am not sure what is going wrong exactly, but here are a couple valid\
1416+ "All declarations start with lower-case letters in Elm, so maybe this letter can\
1417+ \ be changed to lower-case?"
1418+
1419+ _ ->
1420+ D.reflow $
1421+ "Declarations normally start with a lower-case name or the `type` keyword."
1422+ , D.toSimpleHint $
1415− \ declarations for reference:"
1423+ "Here are a couple valid declarations for reference:"
1416 , D.vcat
1424 , D.vcat
1417 [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
1425 [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
1418 , D.fillSep [D.green "add","x","y","="]
1426 , D.fillSep [D.green "add","x","y","="]
@@ -1420,8 +1428,8 @@ toDeclarationsReport source decl =
1420 ]
1428 ]
1421 , D.fillSep [D.cyan "type",D.green "User","=","Anonymous","|","LoggedIn String"]
1429 , D.fillSep [D.cyan "type",D.green "User","=","Anonymous","|","LoggedIn String"]
1422 , D.reflow $
1430 , D.reflow $
1423− "Note that all declarations start with lower-case letters in Elm. Capitalization\
1431+ "Notice that these declarations start with lower-case letters. Capitalization\
1424− \ makes a difference, so be conscious of that if you are working from examples!"
1432+ \ makes a difference in Elm!"
1425 ]
1433 ]
1426 )
1434 )
1427
1435