diff --git a/core/Error.cc b/core/Error.cc index 8bc4df18f..4847172c4 100644 --- a/core/Error.cc +++ b/core/Error.cc @@ -123,8 +123,10 @@ string ErrorSection::toString(const GlobalState &gs) const { string Error::toString(const GlobalState &gs) const { stringstream buf; buf << RESET_STYLE << FILE_POS_STYLE << loc.filePosToString(gs) << RESET_STYLE << ": " << ERROR_COLOR - << restoreColors(header, ERROR_COLOR) << RESET_COLOR << LOW_NOISE_COLOR << " " << gs.errorUrlBase << what.code - << RESET_COLOR; + << restoreColors(header, ERROR_COLOR) << RESET_COLOR; + if (what.code != 25900) { // SCIPRubyDebug + buf << LOW_NOISE_COLOR << " " << gs.errorUrlBase << what.code << RESET_COLOR; + } if (loc.exists()) { auto fileLength = loc.file().data(gs).source().size(); if (loc.beginPos() > fileLength || loc.endPos() > fileLength) { diff --git a/core/GlobalState.cc b/core/GlobalState.cc index 4b1ef1e9b..928cda9ef 100644 --- a/core/GlobalState.cc +++ b/core/GlobalState.cc @@ -1959,6 +1959,7 @@ unique_ptr GlobalState::deepCopy(bool keepId) const { auto result = make_unique(this->errorQueue, this->epochManager); result->silenceErrors = this->silenceErrors; + result->unsilenceErrors = this->unsilenceErrors; result->autocorrect = this->autocorrect; result->ensureCleanStrings = this->ensureCleanStrings; result->runningUnderAutogen = this->runningUnderAutogen; @@ -2055,6 +2056,7 @@ unique_ptr GlobalState::copyForIndex() const { result->files = this->files; result->fileRefByPath = this->fileRefByPath; result->silenceErrors = this->silenceErrors; + result->unsilenceErrors = this->unsilenceErrors; result->autocorrect = this->autocorrect; result->ensureCleanStrings = this->ensureCleanStrings; result->runningUnderAutogen = this->runningUnderAutogen; @@ -2141,9 +2143,14 @@ bool GlobalState::shouldReportErrorOn(Loc loc, ErrorClass what) const { if (what.minLevel == StrictLevel::Internal) { return true; } - if (this->silenceErrors) { + if (this->silenceErrors && !this->unsilenceErrors) { return false; } + if (this->isSCIPRuby && !this->unsilenceErrors) { + if (what.code != 25900) { // SCIPRubyDebug + return false; + } + } if (suppressedErrorClasses.count(what.code) != 0) { return false; } diff --git a/core/GlobalState.h b/core/GlobalState.h index f7a7d726e..6ee1d739d 100644 --- a/core/GlobalState.h +++ b/core/GlobalState.h @@ -223,6 +223,7 @@ class GlobalState final { int globalStateId; bool silenceErrors = false; + bool unsilenceErrors = false; bool autocorrect = false; // We have a lot of internal names of form `` that's chosen with `<` and `>` as you can't make diff --git a/main/options/options.cc b/main/options/options.cc index 573eeed81..905a90250 100644 --- a/main/options/options.cc +++ b/main/options/options.cc @@ -265,6 +265,7 @@ buildOptions(const vector()->default_value(empty.inlineInput), "string"); options.add_options()("files", "Input files", cxxopts::value>()); options.add_options()("q,quiet", "Silence all non-critical errors"); + options.add_options()("unquiet", "(scip-ruby) Show non-critical errors, which are hidden by default"); options.add_options()("v,verbose", "Verbosity level [0-3]"); options.add_options()("h", "Show short help"); options.add_options()("help", "Show long help"); @@ -808,9 +809,14 @@ void readOptions(Options &opts, opts.stopAfterPhase = extractStopAfter(raw, logger); opts.silenceErrors = raw["quiet"].as(); + opts.unsilenceErrors = raw["unquiet"].as(); + if (opts.silenceErrors && opts.unsilenceErrors) { + logger->error("You can't pass both `{}` and `{}`", "--unquiet", "--quiet"); + throw EarlyReturnWithCode(1); + } opts.autocorrect = raw["autocorrect"].as(); opts.inlineInput = raw["e"].as(); - if (opts.autocorrect && opts.silenceErrors) { + if (opts.autocorrect && opts.silenceErrors && !opts.unsilenceErrors) { logger->error("You may not use autocorrect when silencing errors."); throw EarlyReturnWithCode(1); } diff --git a/main/options/options.h b/main/options/options.h index 3bf64c226..2fe5b0f60 100644 --- a/main/options/options.h +++ b/main/options/options.h @@ -156,6 +156,7 @@ struct Options { bool suggestTyped = false; std::optional suggestUnsafe = std::nullopt; bool silenceErrors = false; + bool unsilenceErrors = false; bool silenceDevMessage = false; bool suggestSig = false; bool suppressNonCriticalErrors = false; diff --git a/main/options/test/options_test.cc b/main/options/test/options_test.cc index 866700399..0c1eabe5d 100644 --- a/main/options/test/options_test.cc +++ b/main/options/test/options_test.cc @@ -25,6 +25,7 @@ TEST_CASE("DefaultConstructorMatchesReadOptions") { CHECK_EQ(empty.showProgress, opts.showProgress); CHECK_EQ(empty.suggestTyped, opts.suggestTyped); CHECK_EQ(empty.silenceErrors, opts.silenceErrors); + CHECK_EQ(empty.unsilenceErrors, opts.unsilenceErrors); CHECK_EQ(empty.silenceDevMessage, opts.silenceDevMessage); CHECK_EQ(empty.suggestSig, opts.suggestSig); CHECK_EQ(empty.suppressNonCriticalErrors, opts.suppressNonCriticalErrors); diff --git a/main/realmain.cc b/main/realmain.cc index 368b5a847..ffe144bc2 100644 --- a/main/realmain.cc +++ b/main/realmain.cc @@ -488,6 +488,7 @@ int realmain(int argc, char *argv[]) { if (opts.silenceErrors) { gs->silenceErrors = true; } + gs->unsilenceErrors = opts.unsilenceErrors; if (opts.autocorrect) { gs->autocorrect = true; } diff --git a/scip_indexer/Debug.cc b/scip_indexer/Debug.cc index 1350b21ec..985f51137 100644 --- a/scip_indexer/Debug.cc +++ b/scip_indexer/Debug.cc @@ -8,7 +8,7 @@ namespace sorbet::scip_indexer { -constexpr sorbet::core::ErrorClass SCIPRubyDebug{400, sorbet::core::StrictLevel::False}; +constexpr sorbet::core::ErrorClass SCIPRubyDebug{25900, sorbet::core::StrictLevel::False}; void _log_debug(const sorbet::core::GlobalState &gs, sorbet::core::Loc loc, std::string s) { if (auto e = gs.beginError(loc, SCIPRubyDebug)) {