Skip to content

Commit f28276f

Browse files
committed
Add cpp2:: to "did you mean" hints, closes #431
And addresses b979d19#r115739764
1 parent 7078a5c commit f28276f

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

include/cpp2util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@
201201
#include <type_traits>
202202
#include <new>
203203
#include <memory>
204+
#include <tuple>
204205
#include <string>
205206
#include <string_view>
206207
#include <vector>

regression-tests/test-results/pure2-cpp1-multitoken-fundamental-types-error.cpp2.output

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
pure2-cpp1-multitoken-fundamental-types-error.cpp2...
2-
pure2-cpp1-multitoken-fundamental-types-error.cpp2(3,8): error: 'signed short int' - did you mean 'short'?
2+
pure2-cpp1-multitoken-fundamental-types-error.cpp2(3,8): error: 'signed short int' - did you mean cpp2::'short'?
33
pure2-cpp1-multitoken-fundamental-types-error.cpp2(3,8): error: 'signed short int' is an old-style C/C++ multi-word keyword type
44
- most such types should be used only for interoperability with older code
55
- using those when you need them is fine, but name them with these short names instead:
66
short, ushort, int, uint, long, ulong, longlong, ulonglong, longdouble, __schar, __uchar
77
- see also cpp2util.h > "Convenience names for integer types"
8-
pure2-cpp1-multitoken-fundamental-types-error.cpp2(4,8): error: 'short int signed' - did you mean 'short'?
8+
pure2-cpp1-multitoken-fundamental-types-error.cpp2(4,8): error: 'short int signed' - did you mean cpp2::'short'?
99
pure2-cpp1-multitoken-fundamental-types-error.cpp2(4,8): error: 'short int signed' is an old-style C/C++ multi-word keyword type
1010
- most such types should be used only for interoperability with older code
1111
- using those when you need them is fine, but name them with these short names instead:
1212
short, ushort, int, uint, long, ulong, longlong, ulonglong, longdouble, __schar, __uchar
1313
- see also cpp2util.h > "Convenience names for integer types"
14-
pure2-cpp1-multitoken-fundamental-types-error.cpp2(5,8): error: 'long long unsigned int' - did you mean 'ulonglong'?
14+
pure2-cpp1-multitoken-fundamental-types-error.cpp2(5,8): error: 'long long unsigned int' - did you mean cpp2::'ulonglong'?
1515
pure2-cpp1-multitoken-fundamental-types-error.cpp2(5,8): error: 'long long unsigned int' is an old-style C/C++ multi-word keyword type
1616
- most such types should be used only for interoperability with older code
1717
- using those when you need them is fine, but name them with these short names instead:
1818
short, ushort, int, uint, long, ulong, longlong, ulonglong, longdouble, __schar, __uchar
1919
- see also cpp2util.h > "Convenience names for integer types"
20-
pure2-cpp1-multitoken-fundamental-types-error.cpp2(6,8): error: 'long double' - did you mean 'long'?
20+
pure2-cpp1-multitoken-fundamental-types-error.cpp2(6,8): error: 'long double' - did you mean cpp2::'long'?
2121
pure2-cpp1-multitoken-fundamental-types-error.cpp2(6,8): error: 'long double' is an old-style C/C++ multi-word keyword type
2222
- most such types should be used only for interoperability with older code
2323
- using those when you need them is fine, but name them with these short names instead:
2424
short, ushort, int, uint, long, ulong, longlong, ulonglong, longdouble, __schar, __uchar
2525
- see also cpp2util.h > "Convenience names for integer types"
26-
pure2-cpp1-multitoken-fundamental-types-error.cpp2(7,8): error: 'unsigned char' - did you mean 'u8' (usually best) or '__uchar'?
26+
pure2-cpp1-multitoken-fundamental-types-error.cpp2(7,8): error: 'unsigned char' - did you mean cpp2::'u8' (usually best) or '__uchar'?
2727
pure2-cpp1-multitoken-fundamental-types-error.cpp2(7,8): error: 'unsigned char' is an old-style C/C++ multi-word keyword type
2828
- most such types should be used only for interoperability with older code
2929
- using those when you need them is fine, but name them with these short names instead:

regression-tests/test-results/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
cppfront compiler v0.2.1 Build 8529:1625
2+
cppfront compiler v0.2.1 Build 8531:1630
33
Copyright(c) Herb Sutter All rights reserved
44

55
SPDX-License-Identifier: CC-BY-NC-ND-4.0

source/build.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"8529:1625"
1+
"8531:1630"

source/lex.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ auto lex_line(
669669
if (std::ssize(alt) > 0) {
670670
errors.emplace_back(
671671
pos,
672-
"'" + tokens.back().to_string(true) + "' - did you mean " + alt + "?"
672+
"'" + tokens.back().to_string(true) + "' - did you mean cpp2::" + alt + "?"
673673
);
674674
}
675675
errors.emplace_back(
@@ -1665,7 +1665,7 @@ auto lex_line(
16651665
if (tokens.back() == "static_cast") {
16661666
errors.emplace_back(
16671667
source_position(lineno, i),
1668-
"'static_cast<T>(val)' is not supported in Cpp2 - use 'val as T' for safe conversions instead, or if necessary unsafe_narrow<T>(val) for a possibly-lossy narrowing conversion"
1668+
"'static_cast<T>(val)' is not supported in Cpp2 - use 'val as T' for safe conversions instead, or if necessary cpp2::unsafe_narrow<T>(val) for a possibly-lossy narrowing conversion"
16691669
);
16701670
}
16711671
if (tokens.back() == "dynamic_cast") {

0 commit comments

Comments
 (0)