From ff9cf292dc2b2e8f00f4b6040b95e280f229ada9 Mon Sep 17 00:00:00 2001 From: Bradley Farias Date: Mon, 8 Jan 2024 21:13:25 -0600 Subject: [PATCH] ensure numbers without a raw are allocated during codegen (#1950) This was incorrectly using raw for dynamically generated numbers like in the minifier ( https://github.com/oxc-project/oxc/blob/6e0bd52af13e2add37a2bf444eedc02814f7082b/crates/oxc_minifier/src/compressor/fold.rs#L280 ). This ensures they are dynamically generated during codegen. This does not investigate why `just example minifier` does not take the `if MINIFY` branch. --------- Co-authored-by: Boshen --- crates/oxc_codegen/src/gen.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index bb6163804..ed37a28bb 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -947,7 +947,7 @@ fn need_space_before_dot(bytes: &[u8], p: &mut Codegen<{ MIN impl<'a, const MINIFY: bool> Gen for NumberLiteral<'a> { #[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)] fn gen(&self, p: &mut Codegen<{ MINIFY }>, _ctx: Context) { - if MINIFY { + if MINIFY || self.raw.is_empty() { p.print_space_before_identifier(); let abs_value = self.value.abs();