mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 10:31:03 +01:00
Prevent ref self methods from being called from C++ with an rvalue (#7130)
If the Carbon method takes a `ref self`, give the C++ thunk an lvalue ref-qualifier.
This commit is contained in:
@@ -68,7 +68,7 @@ void F() {
|
||||
}
|
||||
''';
|
||||
|
||||
// --- todo_ref_method_rvalue.carbon
|
||||
// --- fail_ref_method_rvalue.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
import Cpp;
|
||||
|
||||
@@ -78,7 +78,13 @@ class C {
|
||||
|
||||
inline Cpp '''
|
||||
void F() {
|
||||
// TODO: this should be disallowed.
|
||||
// CHECK:STDERR: fail_ref_method_rvalue.carbon:[[@LINE+7]]:3: error: 'this' argument to member function 'M' is an rvalue, but function has non-const lvalue ref-qualifier [CppInteropParseError]
|
||||
// CHECK:STDERR: 17 | Carbon::C().M();
|
||||
// CHECK:STDERR: | ^
|
||||
// CHECK:STDERR: fail_ref_method_rvalue.carbon:[[@LINE-8]]:25: note: 'M' declared here [CppInteropParseNote]
|
||||
// CHECK:STDERR: 5 | fn M[ref self: Self]();
|
||||
// CHECK:STDERR: | ^
|
||||
// CHECK:STDERR:
|
||||
Carbon::C().M();
|
||||
}
|
||||
''';
|
||||
|
||||
Reference in New Issue
Block a user