Add support for 'package' in expressions. (#3445)

This creates a namespace for `package` scope.

It looks like names of class_decls in namespaces lead to an unexpected
instref. This is already true, as best as I can tell. I'm not sure if
there's a preferred approach to address that, so I've left a TODO for
now.
This commit is contained in:
Jon Ross-Perkins
2023-12-04 21:05:41 +00:00
committed by GitHub
parent 1c4a35c76b
commit 30155dbb72
262 changed files with 721 additions and 129 deletions
+24
View File
@@ -0,0 +1,24 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
var x: package.Foo = package.Bar;
// CHECK:STDOUT: - filename: basic.carbon
// CHECK:STDOUT: parse_tree: [
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'Name', text: 'x'},
// CHECK:STDOUT: {kind: 'PackageExpr', text: 'package'},
// CHECK:STDOUT: {kind: 'Name', text: 'Foo'},
// CHECK:STDOUT: {kind: 'MemberAccessExpr', text: '.', subtree_size: 3},
// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'PackageExpr', text: 'package'},
// CHECK:STDOUT: {kind: 'Name', text: 'Bar'},
// CHECK:STDOUT: {kind: 'MemberAccessExpr', text: '.', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]