Skip to content

Commit a238d3e

Browse files
committed
fix -typecheck -verify and experimental features
When using `-enable-experimental-feature` on a non-asserts build, we only emit an error diagnostic that has no source-line information and continue to enable the feature. That doesn't actually prevent use of the experimental feature when you are passing `-typecheck -verify`, since in diagnostics verification mode, a diagnostic with an unknown error location is ignored. Thus, the experimental feature is enabled and run for type-checking, but the compiler would exit with a zero error code. This patch takes a hammer to that escape-hatch, forcing an early non-zero exit the moment an experimental feature is requested. The error message is output to stderr so that CI and other tools should see what happened.
1 parent d6483ae commit a238d3e

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ ERROR(error_unsupported_target_os, none,
3636
ERROR(error_unsupported_target_arch, none,
3737
"unsupported target architecture: '%0'", (StringRef))
3838

39-
ERROR(error_experimental_feature_not_available, none,
40-
"experimental feature '%0' cannot be enabled in a production compiler",
41-
(StringRef))
42-
4339
ERROR(error_upcoming_feature_on_by_default, none,
4440
"upcoming feature '%0' is already enabled as of Swift version %1",
4541
(StringRef, unsigned))

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -812,9 +812,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
812812
if (auto feature = getExperimentalFeature(value)) {
813813
#ifdef NDEBUG
814814
if (!isFeatureAvailableInProduction(*feature)) {
815-
Diags.diagnose(SourceLoc(),
816-
diag::error_experimental_feature_not_available,
817-
A->getValue());
815+
llvm::errs() << "error: experimental feature '" << A->getValue()
816+
<< "' cannot be enabled in a production compiler\n";
817+
exit(1);
818818
}
819819
#endif
820820

0 commit comments

Comments
 (0)