-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make type error fatal to prevent assert failure at later point #8313
Conversation
7a70fa6
to
5d53d3c
Compare
@@ -2,9 +2,8 @@ contract C { | |||
uint256 Test; | |||
|
|||
function f() public { | |||
emit Test(); | |||
emit f(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not what the test is supposed to test...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the idea was to test the code that produces the error message "must emit event" and that one is only output if you use f()
, if you use Test()
you only get "Test is not callable
"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah well, ok maybe it is, but then you can remove the uint256 Test;
above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe best: change Test
to be something callable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
5d53d3c
to
8911b58
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was wondering whether in this particular case, this should really be fatal, but the number of test cases we have about this with comments like "this used to crash" kind of confirms that it's a good idea to just make this fatal :-).
But maybe (independently of this PR) we should have a general discussion about whether to generally always make type errors fatal, whenever you cannot reasonably assign types to all expressions and document that somewhere... Especially, since in the long term and considering stuff like error recovery we might want to deal with all these cases more gracefully... |
Alternatively we could adopt something like an "ErrorType" used in places where the code was supposed to assign a type but errored (and similar dummy constructs) |
Yeah... the problem with that is that we'd probably need special cases for the error type all over... at least that could happen and wouldn't be nice... |
This is missing a changelog entry. |
Created #8316 so that we do not forget it. |
fixes #8283, #8272