Open BookOwl opened 7 years ago
:clap: :100:
I'd say, if you can, make errors like those the Elm compiler creates - actually helpful ones e.g.
The right argument of (+) is causing a type mismatch.
3| 1 + "ohai"
^^^^^^
(+) is expecting the right argument to be a:
number
But the right argument is:
String
Hint: To append strings in Elm, you need to use the (++) operator, not (+).
<http://package.elm-lang.org/packages/elm-lang/core/latest/Basics#++>
Also providing a) compiler warnings and b) line/col numbers is important. It'll be worth creating a function that panics for us 🙂
Yes, and if possible, try/catch clauses
try to <STATEMENT>
e.g.
try to do
display("Hello" / 7) /* This is a type error */
else with VARNAME do
display("Uh oh! An error occurred. Here are the details: " + VARNAME)
end
Right now I'm going to try and make error messages include the line/column that the error message happened.
@joker314 what would that do? I don't think throwing a type error at runtime would make much sense, because the compiler should simply refuse to compile if there is an error like that.
Although I think the types of errors handled in C++ by exceptions (allocation failures and stuff) could be handled through exceptions in Haumea as well
Right now I'm going to try and make error messages include the line/column that the error message happened.
OK, so this is a bit harder than I thought, since it involves changing the Token enum members to include the line/column, which means that I'll have to change quite a bit of code. 😢
f57045f adds line:column info to the error messages! :D
Currently, there is very little error handling. Syntax errors ARE handled, but they don't give very user friendly error messages. Even worse, there is no checking for semantic errors, so the C compiler has to handle them. Since this language is designed to be easy for beginners, this is a problem!