mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 06:41:06 +01:00
Implement unused pattern bindings, continued (#6518)
Implementation of unused pattern bindings #2022, continued. Whereas previous PR #6460 took care of parsing, and PR #6479 prepared the stage by using _ in some test cases, this PR has the the actual implementation, using a simple dataflow analysis. --------- Co-authored-by: Burak Emir <bqe@google.com> Co-authored-by: jonmeow <jperkins@google.com>
This commit is contained in:
co-authored by
Burak Emir
jonmeow
parent
bea24a8bee
commit
fdb188ccfd
+5
-5
@@ -18,7 +18,7 @@ import Cpp;
|
||||
|
||||
// This is valid, unlike in C++, because `Cpp.void` is complete but abstract in
|
||||
// Carbon. Values of type `Cpp.void` exist, but objects of that type do not.
|
||||
fn F(x: Cpp.void) {}
|
||||
fn F(unused x: Cpp.void) {}
|
||||
|
||||
// --- fail_void_abstract.carbon
|
||||
|
||||
@@ -27,14 +27,14 @@ library "[[@TEST_NAME]]";
|
||||
import Cpp;
|
||||
|
||||
fn G() {
|
||||
// CHECK:STDERR: fail_void_abstract.carbon:[[@LINE+7]]:10: error: binding pattern has abstract type `Cpp.void` in `var` pattern [AbstractTypeInVarPattern]
|
||||
// CHECK:STDERR: var x: Cpp.void;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_void_abstract.carbon:[[@LINE+7]]:17: error: binding pattern has abstract type `Cpp.void` in `var` pattern [AbstractTypeInVarPattern]
|
||||
// CHECK:STDERR: var unused x: Cpp.void;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: {{.*}}/prelude/types/cpp/void.carbon:24:1: note: class was declared abstract here [ClassAbstractHere]
|
||||
// CHECK:STDERR: abstract class CppCompat.VoidBase {
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
var x: Cpp.void;
|
||||
var unused x: Cpp.void;
|
||||
}
|
||||
|
||||
// --- fail_void_argument.carbon
|
||||
|
||||
Reference in New Issue
Block a user