Parse vars in classes the same as vars in other locations (#7188)

Class vars are still restricted to simple `name: type` bindings, not
full patterns. This is now handled in the check phase instead of during
parsing.

This is in preparation for supporting `static var`.
This commit is contained in:
Nicholas Bishop
2026-05-13 21:22:46 +00:00
committed by GitHub
parent 5706601096
commit bd918fb33b
91 changed files with 370 additions and 660 deletions
+2 -6
View File
@@ -72,13 +72,9 @@ let (x: {}, y: {}) = ({}, {});
library "[[@TEST_NAME]]";
class C {
// CHECK:STDERR: fail_in_class.carbon:[[@LINE+8]]:7: error: expected identifier in field declaration [ExpectedFieldIdentifier]
// CHECK:STDERR: fail_in_class.carbon:[[@LINE+4]]:20: error: found tuple pattern in class `var` decl [FieldWithTuplePattern]
// CHECK:STDERR: var (x: {}, y: {});
// CHECK:STDERR: ^
// CHECK:STDERR:
// CHECK:STDERR: fail_in_class.carbon:[[@LINE+4]]:3: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
// CHECK:STDERR: var (x: {}, y: {});
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: ^
// CHECK:STDERR:
var (x: {}, y: {});
}