Skip to content

Commit bec654a

Browse files
committed
Allow all unicode characters in package-name input
Error if the input is empty Resolves rdar://104617274
1 parent 347e565 commit bec654a

File tree

3 files changed

+43
-13
lines changed

3 files changed

+43
-13
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ ERROR(error_bad_export_as_name,none,
189189
"export-as name \"%0\" is not a valid identifier",
190190
(StringRef))
191191

192-
ERROR(error_bad_package_name,none,
193-
"package name \"%0\" is not a valid identifier",
194-
(StringRef))
192+
ERROR(error_empty_package_name,none,
193+
"package-name is empty",
194+
())
195195
ERROR(error_stdlib_not_found,Fatal,
196196
"unable to load standard library for target '%0'", (StringRef))
197197
ERROR(error_module_alias_invalid_format,none,

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,8 +821,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
821821

822822
if (const Arg *A = Args.getLastArg(OPT_package_name)) {
823823
auto pkgName = A->getValue();
824-
if (!Lexer::isIdentifier(pkgName))
825-
Diags.diagnose(SourceLoc(), diag::error_bad_package_name, pkgName);
824+
if (StringRef(pkgName).empty())
825+
Diags.diagnose(SourceLoc(), diag::error_empty_package_name);
826826
else
827827
Opts.PackageName = pkgName;
828828
}
Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
// RUN: %empty-directory(%t)
22

3-
// Package name should have valid characters
4-
// RUN: not %target-swift-frontend -module-name Logging -package-name My-Logging%Pkg %s -emit-module -emit-module-path %t/Logging.swiftmodule 2> %t/resultA.output
5-
// RUN: %FileCheck %s -input-file %t/resultA.output -check-prefix CHECK-BAD
6-
// CHECK-BAD: error: package name "My-Logging%Pkg" is not a valid identifier
7-
// CHECK-BAD: error: decl has a package access level but no -package-name was passed
8-
93
// Package name should not be empty
104
// RUN: not %target-swift-frontend -typecheck %s -package-name "" 2>&1 | %FileCheck %s -check-prefix CHECK-EMPTY
11-
// CHECK-EMPTY: error: package name "" is not a valid identifier
5+
// CHECK-EMPTY: error: package-name is empty
126
// CHECK-EMPTY: error: decl has a package access level but no -package-name was passed
137

148
// If package access level is used but no package-name is passed, it should error
@@ -23,5 +17,41 @@
2317
// RUN: %target-swift-frontend -module-name Logging -package-name Swift %s -emit-module -emit-module-path %t/Logging.swiftmodule
2418
// RUN: test -f %t/Logging.swiftmodule
2519

26-
package func log() {}
20+
// Package name can have any unicode characters
21+
22+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name " "
23+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name swift-util.log
24+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name swift$util.log
25+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name swift\$util.log
26+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name swift*util.log
27+
28+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name -swift*util.log
29+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name .swift*util-log
30+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name \#swift#utillog
31+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name swift^util\&lo\(g+@
32+
33+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name swift-util$tools*log
34+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name swift/utils/tools/log.git
35+
36+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name "foo bar baz git"
37+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name My-Logging%Pkg
2738

39+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name Προϊόν
40+
41+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name \n
42+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name “\n”
43+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name \\n
44+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name “\\n”
45+
46+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name “
47+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name ‘
48+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name \‘
49+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name \\‘
50+
51+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name \”
52+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name \\”
53+
54+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name "a \\n b"
55+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name "a \n de-f.g ~!@#$%^&<>?/|:"
56+
57+
package func log() {}

0 commit comments

Comments
 (0)