mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
This should cover: ``` library "lib" api; import Foo library default; import library default; import library "lib"; ``` This splits out `PackageName` and `LibraryName` to their own parse nodes so that checking can ignore them and still get a balanced parse tree (otherwise, we essentially need to implement handling of the parse nodes only to remove the identifiers/string literals -- the optional names mean we can't blindly do that as before). For reference, these nodes don't need to be handled because CheckParseTree will need to directly funnel import information along with checked IRs.
71 lines
1.9 KiB
Plaintext
71 lines
1.9 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
|
|
//
|
|
// AUTOUPDATE
|
|
|
|
// --- api.carbon
|
|
|
|
package Api api;
|
|
|
|
// --- api_lib.carbon
|
|
|
|
package Api library "lib" api;
|
|
|
|
// --- main_lib.carbon
|
|
|
|
library "lib" api;
|
|
|
|
// --- import.carbon
|
|
|
|
import Api;
|
|
// CHECK:STDERR: import.carbon:[[@LINE+6]]:1: ERROR: Library imported more than once.
|
|
// CHECK:STDERR: import Api;
|
|
// CHECK:STDERR: ^
|
|
// CHECK:STDERR: import.carbon:[[@LINE-4]]:1: First import here.
|
|
// CHECK:STDERR: import Api;
|
|
// CHECK:STDERR: ^
|
|
import Api;
|
|
|
|
import Api library "lib";
|
|
// CHECK:STDERR: import.carbon:[[@LINE+6]]:1: ERROR: Library imported more than once.
|
|
// CHECK:STDERR: import Api library "lib";
|
|
// CHECK:STDERR: ^
|
|
// CHECK:STDERR: import.carbon:[[@LINE-4]]:1: First import here.
|
|
// CHECK:STDERR: import Api library "lib";
|
|
// CHECK:STDERR: ^
|
|
import Api library "lib";
|
|
|
|
import library "lib";
|
|
// CHECK:STDERR: import.carbon:[[@LINE+6]]:1: ERROR: Library imported more than once.
|
|
// CHECK:STDERR: import library "lib";
|
|
// CHECK:STDERR: ^
|
|
// CHECK:STDERR: import.carbon:[[@LINE-4]]:1: First import here.
|
|
// CHECK:STDERR: import library "lib";
|
|
// CHECK:STDERR: ^
|
|
import library "lib";
|
|
|
|
// --- default_import.carbon
|
|
|
|
package Api library "not_default" api;
|
|
|
|
import library default;
|
|
// CHECK:STDERR: default_import.carbon:[[@LINE+6]]:1: ERROR: Library imported more than once.
|
|
// CHECK:STDERR: import library default;
|
|
// CHECK:STDERR: ^
|
|
// CHECK:STDERR: default_import.carbon:[[@LINE-4]]:1: First import here.
|
|
// CHECK:STDERR: import library default;
|
|
// CHECK:STDERR: ^
|
|
import library default;
|
|
|
|
// CHECK:STDOUT: file "api.carbon" {
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: file "api_lib.carbon" {
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: file "main_lib.carbon" {
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: file "import.carbon" {
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: file "default_import.carbon" {
|
|
// CHECK:STDOUT: }
|