Files
carbon-lang/toolchain/check/testdata/package_expr/not_found.carbon
T
Richard Smith 20972ec748 Don't perform access-control checks on namespace-scope entities. (#7310)
Instead of silently producing an `ErrorInst::InstId` when looking up a
private qualified name in the current package, bypass the access check.
We don't need it -- private names from other libraries are filtered out
by the import logic.

Also fix `DiagnoseInvalidQualifiedNameAccess` to actually always produce
a diagnostic, instead of silently ignoring access control failures in
non-class types. This is a no-op after the fix to the access logic,
since we only allow access control at class and namespace scope
currently, but should avoid this issue from recurring when that changes.

Assisted-by: Gemini via Antigravity
2026-06-05 23:30:09 +00:00

36 lines
1.3 KiB
Plaintext

// 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
//
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
//
// AUTOUPDATE
// TIP: To test this file alone, run:
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/package_expr/not_found.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/package_expr/not_found.carbon
// --- fail_direct.carbon
library "[[@TEST_NAME]]";
fn F() {
// CHECK:STDERR: fail_direct.carbon:[[@LINE+4]]:23: error: member name `x` not found in `Main` [MemberNameNotFoundInInstScope]
// CHECK:STDERR: var unused y: i32 = package.x;
// CHECK:STDERR: ^~~~~~~~~
// CHECK:STDERR:
var unused y: i32 = package.x;
}
// --- fail_nested.carbon
library "[[@TEST_NAME]]";
private interface Private {}
fn F() {
// CHECK:STDERR: fail_nested.carbon:[[@LINE+4]]:3: error: member name `DoesNotExist` not found in `Private` [MemberNameNotFoundInSpecificScope]
// CHECK:STDERR: package.Private.DoesNotExist;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
package.Private.DoesNotExist;
}