-
Notifications
You must be signed in to change notification settings - Fork 249
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
CI Fix tests #1250
CI Fix tests #1250
Conversation
@@ -10,8 +10,9 @@ class Square : public Shape { }; | |||
|
|||
//--- printing helpers ----------------- | |||
|
|||
print: <T : type> ( msg: std::string, x: T ) | |||
requires !std::convertible_to<T, bool> = | |||
non_bool: <T> concept = !std::convertible_to<T, bool>; |
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.
As mentioned in the description of the PR replacing the requires
expression using this concept
allows GCC 10 to compile the generated C++ code.
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 didn't know that we could write concepts in CPP2 already. Thank you for showing that.
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.
It was a bit of a stab in the dark, but it worked. In fact this overload is not used at all in this test. One of the first things I tried was simply removing it altogether, which also made GCC 10 happy.
Then I tried to come up with a way to rewrite it to be able to keep it.
@@ -26,12 +27,12 @@ print: ( msg: std::string, b: bool ) = | |||
|
|||
main: () -> int = | |||
{ | |||
print( "1.1 is int? ", 1.1 is int ); | |||
print( "1 is int? ", 1 is int ); | |||
::print( "1.1 is int? ", 1.1 is int ); |
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.
Explicit specification of the global namespace fixes an ambiguity issue caused by std::print.
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 was trying to figure out why the cpp1 compiler considers std::print
in this call... it looks like that compiler on some platforms makes them globally accessible.
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 also found it strange, esp. that Clang-18 (C++23) was failing only for mixed-type-safety-1.cpp2
, while MSVC (latest) was failing only for pure2-type-safety-1.cpp
...
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 was trying to figure out why the cpp1 compiler considers std::print in this call... it looks like that compiler on some platforms makes them globally accessible.
cpp2
print( "1 is int? ", 1 is int );
print("\ns* is Shape? ", s* is Shape );
cpp1
print( "1 is int? ", cpp2::impl::is<int>(1));
print("\ns* is Shape? ", cpp2::impl::is<Shape>(*cpp2::impl::assert_not_null(s)));
cpp2::impl::is<...>(...)
in these two calls resolves to std::true_type
, so std::print
is picked up by ADL.
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... right. The argument is from std
namespace. I forgot about this rule.
@gregmarr Thank you!
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.
Yes, I though it was ADL, as I rwrote in the PR description, but I found it strange there was come inconsistency in how differently the recent compiles (MSVC, GCC 14 and Clang-18) behave for mixed-type-safety-1.cpp2
on current main.
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.
Yes, the inconsistency is strange. Do all of those compilers have std::print
available with the compiler options that we are using? Otherwise they must just have different disambiguation rules.
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.
Thanks for figuring this out! This was on my list to look into and I'm glad to see it's been figured out, much appreciated.
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.
Should there be a comment there about why the ::
is needed, so someone doesn't try to remove it in the future?
Should the function just be renamed?
Can we somehow make the user-facing end result of that is
be bool
even when it's the compile-time std::true_type
or std::false_type
so that users don't end up with these same ADL issues? Would that defeat the purpose of using those types in the first place? If so, do the benefits of returning that type outweigh the cost?
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.
In fact renaming crossed my mind, but I thought full qualification would have extra educational value.
I wile the idea of adding a comment.
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.
Looks good!
Thanks! |
What's the best way to resolve the two Normally I'd use the web editor but the button is disabled, saying the conflicts are too complex for the web editor. |
Rebased with conflicts resolved. |
Thank you! |
I have added a comment and I propose to leave the solution with full qualification as it often is helpful when problems with ADL arise (speaking from my own experience).
This is neverending and the devil is in the details... |
Urk, it says to resolve conflicts again -- sorry, I may have done that because I just pushed a commit. 😞 Sorry, I didn't think it would interfere with this. I don't know why it disables the "Resolve conflicts" button claiming that the conflicts are too complex to resolve in the web editor, those three files are not that long or complex. Sigh, sorry about that. I tried pulling the branch and rerunning regression on my machine but that didn't hit these files. If you can re-fix these in the next couple of days I'll hold off on other commits. |
I will rebase this on #1256 that already makes all tests green. |
It is fixed. In fact this PR is now based on the updates in #1256. You can merge #1256 first. |
Thanks! I have merged #1256. For some reason this is still showing conflicts that cannot be resolved in the web editor:
Now that the conflicts are limited to |
This is weird: Only one of those two files exists in the branch. I tried deleting that one and pushed that, but it seems to have had no effect on the merge conflict. Any ideas? |
I will try to fix that soon (as in later today). |
Ready to merge. |
Thanks! |
mixed-type-safety-1.cpp2
andpure2-type-safety-1.cpp
with C++23.std::print()
function added in C++23 caused issues with ADL leading to ambiguities of theprint
function template defined in the test itself.requires
expressions.concept
to replace therequires
expression.