From 5428392b98aa1d0741a1747f6849265a88d12220 Mon Sep 17 00:00:00 2001 From: Adam Welc Date: Sat, 29 Jun 2024 10:27:15 -0700 Subject: [PATCH] [move-ide] Macro expansion crash workaround (#18466) ## Description This is a workaround for an issue with IDE caching pre-compiled binaries which do not include source code needed for macro expansion. It's only a workaround to avoid `move-analyzer` crashing rather than a proper fix. --- external-crates/move/crates/move-compiler/src/hlir/translate.rs | 2 +- .../move/crates/move-compiler/src/typing/translate.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/external-crates/move/crates/move-compiler/src/hlir/translate.rs b/external-crates/move/crates/move-compiler/src/hlir/translate.rs index b23e5909f1fad..b9063433d51dc 100644 --- a/external-crates/move/crates/move-compiler/src/hlir/translate.rs +++ b/external-crates/move/crates/move-compiler/src/hlir/translate.rs @@ -1606,7 +1606,7 @@ fn value( error_exp(eloc) } E::UnresolvedError => { - assert!(context.env.has_errors()); + assert!(context.env.has_errors() || context.env.ide_mode()); make_exp(HE::UnresolvedError) } }; diff --git a/external-crates/move/crates/move-compiler/src/typing/translate.rs b/external-crates/move/crates/move-compiler/src/typing/translate.rs index ee2c53b7b46e8..69538c7cc9cdd 100644 --- a/external-crates/move/crates/move-compiler/src/typing/translate.rs +++ b/external-crates/move/crates/move-compiler/src/typing/translate.rs @@ -4441,7 +4441,7 @@ fn expand_macro( let res = match macro_expand::call(context, call_loc, m, f, type_args.clone(), args, return_ty) { None => { - assert!(context.env.has_errors()); + assert!(context.env.has_errors() || context.env.ide_mode()); (context.error_type(call_loc), TE::UnresolvedError) } Some(macro_expand::ExpandedMacro {