Your ideas on: Good Error messages in compiler?

Hey everybody, the compiler actually knows a lot more about errors than it tells you, especially when using the http_sophia it’s often thin-lipped and the reported lines and columns semantically not always match with where the mistake is actually occurring. Also, the error is not really well parsable as of for now, unless you like using regex for parsing error strings :wink:

This is the error format I would like to propose, is there anything missing? What would you like to have added?

{
	"file": "MyContract.aes",
	"contract": "someContract",
	"startLine": "42",
	"startColumn": "42",
	"endLine": "42", // if applicable
	"endColumn": "42", // if applicable
	"errorCode": "1",
	"message": "Forbidden token - only Ulf Norell is allowed to use virtual semicolons",
	"quickfix": "Use a real semicolon instead"
}

About the quickfix: There already some quite intelligent suggestions happening in the cli version of the compiler, like telling you how to edit your code to adhere to the newer sophia syntax using entrypoints. So if there is something available for that, we might break the quickfix property down further into an array of further issue objects like the one above.

What do you think ?

5 Likes

I would rather change errorCode from ints to string-enums like "type_error", "syntax_error", "segfault". It will be just more readable and safer imo

2 Likes

That seems great to me. Everything different than “unexpected token con” & “unexpected token vsemi” is good though. For me the most important from this object is the startingLine and message. If those two are readable and correct I think we are fine.

Best,
Martin

2 Likes

Yeah, something should be done regarding the error messages.

The proposition seems good @nikitafuchs.chain!

1 Like