-
Notifications
You must be signed in to change notification settings - Fork 445
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
Unifying struct and list expressions fix (#3057) #3122
Conversation
@@ -0,0 +1,6 @@ | |||
issue3057-1.p4(11): [--Werror=type-error] error: ==: cannot compare initializers with unknown types |
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 message isn't very good. I know you didn't change this, but perhaps you can fix it.
The message should say "cannot compare structure-valued expressions with unknown types".
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 expect that you will need to change these reference files now that the error message has changed.
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 good, but I would appreciate the small changes requested.
Ideally you should have first filed an issue for the bug that you are fixing.
Hi, @mbudiu-vmw, I implemented the small changes you requested. |
… and structs p4lang#3057 * I corrected the code so that the compiler bug does not occur when comparing structures of unknown type, but to report an error * I enabled a comparison between the structure/list expression so that the cast can be put on either side. Before this change, if the cast was on the right side of the comparison operator error was reported. * Added tests which verify the above
Hi @mbudiu-vmw, I implemented the changes you requested, but I forgot to change the output in the test, now I did it too. |
Unifying struct and list expressions fix (#3057)
I corrected the code so that the compiler bug does not occur when comparing structures of unknown type, but to report an error
I enabled a comparison between the structure/list expression so that the cast can be put on either side. Before this change, if the cast was on the right side of the comparison operator error was reported.
Added tests which verify the above
bool b2 = { a = 8w1, b = 8w2 } == { a = 8w1, b = 8w2 };
bool b21 = { a = 32w1, b = 32w2 } == { a = 32w1, b = 32w2 };
bool b3 = { a = 1, b = 2 } == {1, 2};
It is not logical that mockery is possible if we do not put a cast on one of the sides
Because what if we had two structures
struct S {
bit<32> a;
bit<32> b;
}
struct Q {
bit<32> a;
bit<32> b;
}
or in an even worse case, we do not have a single structure defined.
bool b5_ = { a = 1, b = 2 } == (S) { a = 1, b = 2 };
I enabled a comparison between the structure/list expression so that the cast can be put on either side. Before this change, if the cast was on the right side of the comparison operator error was reported.