From e418f6533de519d0136794b39c2c383bc55950c9 Mon Sep 17 00:00:00 2001 From: Hunter Goldstein Date: Thu, 17 Mar 2022 16:57:16 -0700 Subject: [PATCH] `panic` when asked for a module in `ExternalDeclProvider` Summary: While reviewing the previous stack w/ jakebailey he noted that I probably ought to panic here rather than always state that modules don't exist. My initial reasoning was defensive: HackC crashes are *bad* as they're difficult to surface to users. It's technically correct to say modules never exist in this position as they (currently) aren't exposed to the runtime Jake's reasoning was that in the event that we *do* expose modules to the runtime, and they're asked for in this position, it's going to be confusing to debug if they're all not found. Additionally, asking for modules *at all* until that time is definitely a mistake. This fails loudly rather than silently. Differential Revision: D34940879 fbshipit-source-id: d424e5d621907883b1570fcf5b707af096fa448c --- hphp/hack/src/hackc/decl_provider/external.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hphp/hack/src/hackc/decl_provider/external.rs b/hphp/hack/src/hackc/decl_provider/external.rs index 559f4d80d73..dbedf68cbd7 100644 --- a/hphp/hack/src/hackc/decl_provider/external.rs +++ b/hphp/hack/src/hackc/decl_provider/external.rs @@ -92,9 +92,14 @@ impl<'decl> DeclProvider<'decl> for ExternalDeclProvider<'decl> { NameType::Typedef => 3, // HPHP::AutoloadMap::KindOf::TypeAlias NameType::Fun => 1, // HPHP::AutoloadMap::KindOf::Function NameType::Const => 2, // HPHP::AutoloadMap::KindOf::Constant - // TODO(T108206307, T111380364) During decls in compilation pretend like modules don't - // exist - NameType::Module => return Err(Error::NotFound), + // TODO(T108206307, T111380364) During decls-in-compilation, we should actively panic + // if we're asking for a module. We *could* just say that all modules are not found, + // defensively, but that might make it harder to debug in the future if we try to + // use modules for decls-in-compilation. + NameType::Module => panic!( + "Cannot request `{}` as a module decl; fetching module decls is not supported", + symbol + ), }; let result = unsafe { // Invoke extern C/C++ provider implementation. -- 2.11.4.GIT