-
Notifications
You must be signed in to change notification settings - Fork 260
[BUG] Generalize _string-literal_ of contract like C++26's static_assert
#751
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
Comments
I mentioned at #831 (comment) that I had written something like Now, since commit 2893e64, contracts are conditionally evaluated. Although what we really want is lazy arguments/parameters. [ Note 1: constexpr auto wdl = Sunday[last]; // wdl is the last Sunday of an as yet unspecified month
static_assert(wdl.weekday() == Sunday); Poor code takes built-in |
Unless/until we have the ability to have an argument that is not evaluated, you could just protect the
|
Fixed, thanks! |
Title: Generalize string-literal of contract like C++26's
static_assert
.Description:
Custom text output after a contract failure isn't part of the Contracts' MVP.
If Cpp2's contracts feature is going to have this anyways,
we could craft better diagnostics messages
if its second argument behaved like that of
static_assert
in C++26.Minimal reproducer (https://cpp2.godbolt.org/z/GYqdx3WTE):
Commands:
cppfront main.cpp2 clang++18 -std=c++26 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cpp
Expected result:
Program returned: 0
.Actual result and error:
main.cpp2(4,47): error: expected contract message string (at 'std')
.See also:
The text was updated successfully, but these errors were encountered: