-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-enable file/line/function info on contracts violations + usabili…
…ty improvements Thanks @MikeShah for your YouTube video here: https://youtu.be/ZslemeHsOjk?si=qPoNdJLxBoSgFh6b . I'm treating the video as a "looking over your shoulder using Cpp2" mini-UX study to make a better experience for folks coming to the syntax the first time... Diagnose attempt to declare two things at once, e.g., `x,y : int = 5;` Diagnose attempt to for-loop over two ranges, e.g., `for x,y do ..` Automatically use <source_location>, including for file/line/function information on contracts checks so when using a capable compiler you get nice bounds/other violation messages out of the box that point directly to the offending source line Remove the -add-source-info flag as no longer needed, now <source_location> is now reliable and automated (modulo a workaround in cpp2util.h for an MSVC bug where importing source_location via a module doesn't work correctly)
- Loading branch information
Showing
26 changed files
with
92 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
regression-tests/test-results/gcc-14-c++2b/mixed-bounds-check.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4] | ||
mixed-bounds-check.cpp2(9) int main(): Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4] |
2 changes: 1 addition & 1 deletion
2
regression-tests/test-results/gcc-14-c++2b/mixed-bounds-safety-with-assert.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Bounds safety violation | ||
mixed-bounds-safety-with-assert.cpp2(11) void print_subrange(const auto:89&, cpp2::impl::in<int>, cpp2::impl::in<int>) [with auto:89 = std::vector<int>; cpp2::impl::in<int> = const int]: Bounds safety violation |
20 changes: 10 additions & 10 deletions
20
regression-tests/test-results/gcc-14-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
In file included from mixed-bugfix-for-ufcs-non-local.cpp:6: | ||
../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type | ||
2100 | template<typename T> | ||
2100 | { | ||
| ^ | ||
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ | ||
2137 | class c_raii { | ||
2137 | // Speculative: RAII wrapping for the C standard library | ||
| ^ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:13:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:13:36: error: template argument 1 is invalid | ||
../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type | ||
2100 | template<typename T> | ||
2100 | { | ||
| ^ | ||
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ | ||
2137 | class c_raii { | ||
2137 | // Speculative: RAII wrapping for the C standard library | ||
| ^ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid | ||
../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type | ||
2100 | template<typename T> | ||
2100 | { | ||
| ^ | ||
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ | ||
2137 | class c_raii { | ||
2137 | // Speculative: RAII wrapping for the C standard library | ||
| ^ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:31:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:31:36: error: template argument 1 is invalid | ||
../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type | ||
2100 | template<typename T> | ||
2100 | { | ||
| ^ | ||
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ | ||
2137 | class c_raii { | ||
2137 | // Speculative: RAII wrapping for the C standard library | ||
| ^ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:33:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:33:36: error: template argument 1 is invalid | ||
../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type | ||
2100 | template<typename T> | ||
2100 | { | ||
| ^ | ||
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ | ||
2137 | class c_raii { | ||
2137 | // Speculative: RAII wrapping for the C standard library | ||
| ^ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid |
2 changes: 1 addition & 1 deletion
2
.../test-results/gcc-14-c++2b/mixed-initialization-safety-3-contract-violation.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Contract violation: fill: value must contain at least count elements | ||
mixed-initialization-safety-3-contract-violation.cpp2(25) void fill(cpp2::impl::out<std::__cxx11::basic_string<char> >, cpp2::impl::in<std::__cxx11::basic_string<char> >, cpp2::impl::in<int>): Contract violation: fill: value must contain at least count elements |
1 change: 1 addition & 0 deletions
1
...on-tests/test-results/gcc-14-c++2b/mixed-lifetime-safety-and-null-contracts.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
sending error to my framework... [dynamic null dereference attempt detected] | ||
from source location: mixed-lifetime-safety-and-null-contracts.cpp2(17) void try_pointer_stuff()] |
2 changes: 1 addition & 1 deletion
2
regression-tests/test-results/gcc-14-c++2b/pure2-assert-expected-not-null.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Null safety violation: std::expected has an unexpected value | ||
pure2-assert-expected-not-null.cpp2(15) int bad_expected_access(): Null safety violation: std::expected has an unexpected value |
2 changes: 1 addition & 1 deletion
2
regression-tests/test-results/gcc-14-c++2b/pure2-assert-optional-not-null.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Null safety violation: std::optional does not contain a value | ||
pure2-assert-optional-not-null.cpp2(14) int bad_optional_access(): Null safety violation: std::optional does not contain a value |
2 changes: 1 addition & 1 deletion
2
regression-tests/test-results/gcc-14-c++2b/pure2-assert-shared-ptr-not-null.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Null safety violation: std::shared_ptr is empty | ||
pure2-assert-shared-ptr-not-null.cpp2(15) int bad_shared_ptr_access(): Null safety violation: std::shared_ptr is empty |
2 changes: 1 addition & 1 deletion
2
regression-tests/test-results/gcc-14-c++2b/pure2-assert-unique-ptr-not-null.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Null safety violation: std::unique_ptr is empty | ||
pure2-assert-unique-ptr-not-null.cpp2(15) int bad_unique_ptr_access(): Null safety violation: std::unique_ptr is empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
regression-tests/test-results/msvc-2022-c++latest/mixed-bounds-check.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4] | ||
mixed-bounds-check.cpp2(9) int __cdecl main(void): Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4] |
2 changes: 1 addition & 1 deletion
2
...sion-tests/test-results/msvc-2022-c++latest/mixed-bounds-safety-with-assert.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Bounds safety violation | ||
mixed-bounds-safety-with-assert.cpp2(11) void __cdecl print_subrange<class std::vector<int,class std::allocator<int> >>(const class std::vector<int,class std::allocator<int> > &,const int,const int): Bounds safety violation |
2 changes: 1 addition & 1 deletion
2
...esults/msvc-2022-c++latest/mixed-initialization-safety-3-contract-violation.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Contract violation: fill: value must contain at least count elements | ||
mixed-initialization-safety-3-contract-violation.cpp2(25) void __cdecl fill(class cpp2::impl::out<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,const int): Contract violation: fill: value must contain at least count elements |
1 change: 1 addition & 0 deletions
1
...s/test-results/msvc-2022-c++latest/mixed-lifetime-safety-and-null-contracts.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
sending error to my framework... [dynamic null dereference attempt detected] | ||
from source location: mixed-lifetime-safety-and-null-contracts.cpp2(17) void __cdecl try_pointer_stuff(void)] |
2 changes: 1 addition & 1 deletion
2
...ssion-tests/test-results/msvc-2022-c++latest/pure2-assert-expected-not-null.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Null safety violation: std::expected has an unexpected value | ||
pure2-assert-expected-not-null.cpp2(15) int __cdecl bad_expected_access(void): Null safety violation: std::expected has an unexpected value |
2 changes: 1 addition & 1 deletion
2
...ssion-tests/test-results/msvc-2022-c++latest/pure2-assert-optional-not-null.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Null safety violation: std::optional does not contain a value | ||
pure2-assert-optional-not-null.cpp2(14) int __cdecl bad_optional_access(void): Null safety violation: std::optional does not contain a value |
2 changes: 1 addition & 1 deletion
2
...ion-tests/test-results/msvc-2022-c++latest/pure2-assert-shared-ptr-not-null.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Null safety violation: std::shared_ptr is empty | ||
pure2-assert-shared-ptr-not-null.cpp2(15) int __cdecl bad_shared_ptr_access(void): Null safety violation: std::shared_ptr is empty |
2 changes: 1 addition & 1 deletion
2
...ion-tests/test-results/msvc-2022-c++latest/pure2-assert-unique-ptr-not-null.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Null safety violation: std::unique_ptr is empty | ||
pure2-assert-unique-ptr-not-null.cpp2(15) int __cdecl bad_unique_ptr_access(void): Null safety violation: std::unique_ptr is empty |
2 changes: 1 addition & 1 deletion
2
regression-tests/test-results/pure2-statement-parse-error.cpp2.output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
pure2-statement-parse-error.cpp2... | ||
pure2-statement-parse-error.cpp2(3,9): error: invalid statement encountered inside a compound-statement (at 'b') | ||
pure2-statement-parse-error.cpp2(3,5): error: invalid statement encountered inside a compound-statement (at 'int') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
"9712:1020" | ||
"9713:1156" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
"v0.7.0" | ||
"v0.7.1" |
1 comment
on commit 8504e86
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.
You are most welcome! :)
@hsutter You have a
]
here without a corresponding[
.