Skip to content

Commit

Permalink
fix syntax error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
AshleyYakeley committed Apr 22, 2024
1 parent 6825b10 commit fd1b832
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
7 changes: 3 additions & 4 deletions Pinafore/pinafore-language/lib/Pinafore/Language/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,9 @@ instance ShowNamedText QErrorType where
then Nothing
else return $ toText s)
msgs
msgsUnExpect =
msgsSysUnExpect =
getMsgs $ \case
SysUnExpect s -> Just s
UnExpect s -> Just s
_ -> Nothing
msgsExpect =
getMsgs $ \case
Expand All @@ -125,15 +124,15 @@ instance ShowNamedText QErrorType where
semicolon a "" = a
semicolon a b = a <> "; " <> b
strUnexpected =
case msgsUnExpect of
case msgsSysUnExpect of
[] -> ""
s -> "unexpected: " <> intercalate ", " s
strExpecting =
case msgsExpect of
[] -> ""
s -> "expecting: " <> intercalate ", " s
strMessage = intercalate "; " msgsMessage
in "syntax error: " <> (toNamedText $ strUnexpected `semicolon` strExpecting `semicolon` strMessage)
in "syntax: " <> (toNamedText $ strUnexpected `semicolon` strExpecting `semicolon` strMessage)
showNamedText (PatternErrorError e) = showNamedText e
showNamedText (ExpressionErrorError nn) =
"undefined: " <>
Expand Down
3 changes: 2 additions & 1 deletion Pinafore/pinafore-language/test/Test/Entity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,8 @@ testEntity =
, testExpectSuccess "testaction (Right 5) $ evaluate @Integer \"let x = 5 in x\""
, testExpectSuccess
"do ar <- evaluate @(Integer -> Integer) \"fn x => x +.Integer 1\"; ar >- match Left err => fail err; Right f => testeqval 8 $ f 7 end end"
, testExpectSuccess "testaction (Left \"<evaluate>:1:1: expecting: expression\") $ evaluate @Integer \"\""
, testExpectSuccess
"testaction (Left \"<evaluate>:1:1: syntax: expecting: expression\") $ evaluate @Integer \"\""
, testExpectSuccess "testaction (Left \"<evaluate>:1:1: undefined: f: a\") $ evaluate @Integer \"f\""
, testExpectSuccess "testleft $ evaluate @Integer \"\\\"hello\\\"\""
, testExpectSuccess
Expand Down
6 changes: 3 additions & 3 deletions Pinafore/pinafore-language/test/interactive/errors.ref
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pinafore> )
<input>:1:1: unexpected: ")"; expecting: end of input, pattern, expression
<input>:1:1: syntax: unexpected: ")"; expecting: end of input, pattern, expression
pinafore> (
<input>:1:1: expecting: expression
<input>:1:1: syntax: expecting: expression
pinafore> in
<input>:1:1: unexpected: "in"; expecting: end of input, pattern, expression
<input>:1:1: syntax: unexpected: "in"; expecting: end of input, pattern, expression
pinafore> a
<input>:2:1: undefined: a: a
pinafore> a
Expand Down

0 comments on commit fd1b832

Please sign in to comment.