v icon indicating copy to clipboard operation
v copied to clipboard

checker: fix and improve return stmt error messages

Open felipensp opened this issue 3 years ago • 4 comments

Fix #17473

felipensp avatar Mar 02 '23 21:03 felipensp

This doesn't look correct. You should be able to do return none because of the ? declaration as the return type. You just shouldn't be able to return anything else.

I would expect this particular error to be something like "can only return none from an Option-only return function" or something similar.

JalonSolov avatar Mar 03 '23 00:03 JalonSolov

This doesn't look correct. You should be able to do return none because of the ? declaration as the return type. You just shouldn't be able to return anything else.

I would expect this particular error to be something like "can only return none from an Option-only return function" or something similar.

Return none is ok. The problem is the multiple return. This is what I am checking.

felipensp avatar Mar 03 '23 01:03 felipensp

Your current error message doesn't say anything about what the problem is...

error: unexpected argument, current function does not return anything

This is incorrect, as it could return none, but it might not return anything (if it succeeded). That's why I suggested an alternative error message, which directly relates to the problem.

JalonSolov avatar Mar 03 '23 01:03 JalonSolov

Your current error message doesn't say anything about what the problem is...

error: unexpected argument, current function does not return anything

This is incorrect, as it could return none, but it might not return anything (if it succeeded). That's why I suggested an alternative error message, which directly relates to the problem.

Ah Yes. Agreed.

felipensp avatar Mar 03 '23 02:03 felipensp