solidity icon indicating copy to clipboard operation
solidity copied to clipboard

Make usage of quotes in errors consistent

Open Marenz opened this issue 7 years ago • 28 comments

Our error messages are not consistent regarding the use of quotes, e.g. some quote the function name and contract name, others don't.

We should agree on how we want to do that and make it consistent everywhere.

@erak argues for double quotes " around all user defined names. I tend to agree.

Marenz avatar Oct 28 '19 14:10 Marenz

Hey, I would be happy to improve the error messages!

birtony avatar Oct 29 '19 16:10 birtony

Glad to hear that!

We still have to decide on how exactly this should be done, which we probably will do in tomorrows meeting. Feel free to join tomorrow (Wednesday at 15 CET, a link will be posted in gitter) in our google hangout meeting if you want to talk about it.

In any case I'll update this issue with the result of the discussion!

Marenz avatar Oct 29 '19 16:10 Marenz

Thank you, @Marenz!

birtony avatar Oct 29 '19 22:10 birtony

Hey @Marenz! Unfortunately I could not join you for the meeting today. Have you been able to reach any agreement on this issue?

birtony avatar Oct 30 '19 16:10 birtony

Yes. We'd like for all user defined names to be in quotes in all error messages. Sorry I didn't update sooner.

Marenz avatar Oct 31 '19 11:10 Marenz

In single or in double quotes?

birtony avatar Oct 31 '19 12:10 birtony

Double quotes

Marenz avatar Nov 04 '19 17:11 Marenz

I was looking into the error messages, and I have also noticed, that a lot of custom defined errors are used. The problem is that I am not totally sure, which exact errors should be changed. Could you, please, provide me with an example of any error that has "user defined names" within it that needs to be updated?

birtony avatar Nov 21 '19 17:11 birtony

Here are a few examples for you: :)

// Uses single quotes instead of double quotes
m_errorReporter.warning(_statement.location(), "Failure condition of 'send' ignored. Consider using 'transfer' instead.");
// Should be this
m_errorReporter.warning(_statement.location(), "Failure condition of \"send\" ignored. Consider using \"transfer\" instead.");

here no quotes at all are used:

m_errorReporter.typeError(
        _statement.location(),
        errorMsg +
        ". Try converting to type " +
        valueComponentType->mobileType()->toString() +
        " or use an explicit conversion."
);
// Should be this
m_errorReporter.typeError(
        _statement.location(),
        errorMsg +
        ". Try converting to type \"" +
        valueComponentType->mobileType()->toString() +
        "\" or use an explicit conversion."
);


 m_errorReporter.fatalTypeError(_tuple.location(), "Type " + inlineArrayType->toString() + " is only valid in storage.");
// Should be this
 m_errorReporter.fatalTypeError(_tuple.location(), "Type \"" + inlineArrayType->toString() + "\" is only valid in storage.");

Marenz avatar Nov 26 '19 15:11 Marenz

Hey, @Marenz Is this still left to work upon? I would be glad to contribute.

KalshuCodes avatar Dec 07 '19 18:12 KalshuCodes

@kalashshah11 I am going to push an update in a bit with all the updated error messages I could've found

birtony avatar Dec 07 '19 19:12 birtony

Why not introduce a toQuoted or toQuotedString helper?

axic avatar Dec 08 '19 12:12 axic

@axic such as https://github.com/ethereum/solidity/issues/7733 ? ;)

leonardoalt avatar Dec 08 '19 22:12 leonardoalt

Can't we just implement our alternative in 3 lines of code?

axic avatar Dec 08 '19 23:12 axic

Sure, that'd work

leonardoalt avatar Dec 08 '19 23:12 leonardoalt

When @erak and I talked about it we decided to make it all consistent as a first step and as a second step use a function like that.

Marenz avatar Dec 09 '19 09:12 Marenz

Sounds like a lot of extra work :wink:

axic avatar Dec 09 '19 09:12 axic

I argued along similar lines and I forgot eraks counter-argument ;)

Marenz avatar Dec 09 '19 10:12 Marenz

Well, I think I had no strong opinion on the process ;-) Would agree with @axic here and start using the helper function right away.

erak avatar Dec 09 '19 10:12 erak

What does that mean in regards to the pending PR?

Marenz avatar Dec 09 '19 11:12 Marenz