diff --git a/src/bundler/LinkerGraph.rs b/src/bundler/LinkerGraph.rs index 8379670d81ff..f685b39c371c 100644 --- a/src/bundler/LinkerGraph.rs +++ b/src/bundler/LinkerGraph.rs @@ -1015,20 +1015,6 @@ pub struct File { pub quoted_source_contents: Option>, } -impl Default for File { - fn default() -> Self { - Self { - // Note: empty static-arm bitset; load() overwrites before any read. - entry_bits: AutoBitSet::init_empty(0).expect("static AutoBitSet"), - input_file: Index::source(0u32), - entry_point_kind: EntryPoint::Kind::None, - entry_point_chunk_index: u32::MAX, - line_offset_table: bun_sourcemap::line_offset_table::List::new_in(bun_alloc::AstAlloc), - quoted_source_contents: None, - } - } -} - pub(crate) type FileList = MultiArrayList; bun_collections::multi_array_columns! { diff --git a/src/bundler/ParseTask.rs b/src/bundler/ParseTask.rs index 44d4bb95add6..7428ff1337de 100644 --- a/src/bundler/ParseTask.rs +++ b/src/bundler/ParseTask.rs @@ -162,13 +162,11 @@ impl bun_event_loop::Taskable for Result { pub(crate) enum ResultValue { Success(Success), Err(ResultError), - Empty { source_index: Index }, } impl ResultValue { pub(crate) fn source_index(&self) -> u32 { match self { - ResultValue::Empty { source_index } => source_index.get(), ResultValue::Err(data) => data.source_index.get(), ResultValue::Success(val) => val.source.index.0, } @@ -2841,13 +2839,6 @@ pub mod parse_worker { break 'value ResultValue::Success(ast); } Err(e) => { - if e == crate::Error::EmptyAST { - drop(log); - break 'value ResultValue::Empty { - source_index: this.source_index, - }; - } - break 'value ResultValue::Err(ResultError { err: e, step, @@ -2931,7 +2922,6 @@ pub mod parse_worker { match &mut result.value { ResultValue::Success(s) => drop(core::mem::take(&mut s.log)), ResultValue::Err(e) => drop(core::mem::take(&mut e.log)), - ResultValue::Empty { .. } => {} } } diff --git a/src/bundler/bundle_v2.rs b/src/bundler/bundle_v2.rs index 6ed38562e915..5ed8a9fb9bb6 100644 --- a/src/bundler/bundle_v2.rs +++ b/src/bundler/bundle_v2.rs @@ -7630,23 +7630,6 @@ pub mod bv2_impl { } match &mut parse_result.value { - parse_task::ResultValue::Empty { - source_index: empty_source_index, - } => { - let empty_idx = (*empty_source_index).get() as usize; - this.graph.input_files.items_side_effects_mut()[empty_idx] = - bun_ast::SideEffects::NoSideEffectsEmptyAst; - if cfg!(debug_assertions) { - bun_core::scoped_log!( - Bundle, - "onParse({}, {}) = empty", - empty_idx, - bstr::BStr::new( - &this.graph.input_files.items_source()[empty_idx].path.text - ) - ); - } - } parse_task::ResultValue::Success(result) => { // SAFETY: `transpiler.log` is a live BACKREF set in BundleV2::init. result diff --git a/src/bundler/error.rs b/src/bundler/error.rs index cffebb56e1bd..6741d2ca4386 100644 --- a/src/bundler/error.rs +++ b/src/bundler/error.rs @@ -1,7 +1,5 @@ #[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)] pub enum Error { - #[error("ModuleNotFound")] - ModuleNotFound, #[error("BuildFailed")] BuildFailed, #[error("CompilationFailed")] @@ -30,8 +28,6 @@ pub enum Error { MinifyError, #[error("InvalidNativePlugin")] InvalidNativePlugin, - #[error("EmptyAST")] - EmptyAST, #[error("FormatError")] FormatError, #[error("ResolveMessage")] @@ -102,7 +98,6 @@ impl Error { #[allow(clippy::trivially_copy_pass_by_ref)] pub fn name(&self) -> &'static str { match self { - Self::ModuleNotFound => "ModuleNotFound", Self::BuildFailed => "BuildFailed", Self::CompilationFailed => "CompilationFailed", Self::Plugin => "Plugin", @@ -117,7 +112,6 @@ impl Error { Self::SyntaxError => "SyntaxError", Self::MinifyError => "MinifyError", Self::InvalidNativePlugin => "InvalidNativePlugin", - Self::EmptyAST => "EmptyAST", Self::FormatError => "FormatError", Self::ResolveMessage => "ResolveMessage", Self::Js(bun_core::JsError::OutOfMemory) => "OutOfMemory", diff --git a/src/bundler/transpiler.rs b/src/bundler/transpiler.rs index 3821fc09304a..d14f8d5ef2ad 100644 --- a/src/bundler/transpiler.rs +++ b/src/bundler/transpiler.rs @@ -1466,7 +1466,6 @@ impl<'a> Transpiler<'a> { ignore_dce_annotations: self.options.ignore_dce_annotations, preserve_unused_imports_ts: false, use_define_for_class_fields: this_parse.use_define_for_class_fields, - suppress_warnings_about_weird_code: true, features: js_ast::RuntimeFeatures::default(), tree_shaking: self.options.tree_shaking, bundle: false, diff --git a/src/install/PackageManager/PackageJSONEditor.rs b/src/install/PackageManager/PackageJSONEditor.rs index cf7208abb790..11e305475add 100644 --- a/src/install/PackageManager/PackageJSONEditor.rs +++ b/src/install/PackageManager/PackageJSONEditor.rs @@ -1035,15 +1035,6 @@ pub(crate) fn edit( if let Some(value) = query.expr.as_property(name) { if matches!(value.expr.data, bun_ast::ExprData::EString(_)) { - // `bun update ` keeps a `catalog:` reference intact. - let keep_catalog_reference = manager.subcommand - == Subcommand::Update - && value.expr.as_utf8_string_literal().is_some_and( - |version_literal| { - literal_tag(version_literal) - == dependency::Tag::Catalog - }, - ); let in_target_list = strings::eql_long(list, dependency_list, true); @@ -1051,7 +1042,6 @@ pub(crate) fn edit( if request.package_id != INVALID_PACKAGE_ID && manager.subcommand != Subcommand::Update && in_target_list - && !keep_catalog_reference { replacing += 1; } else if move_to_target && !in_target_list { diff --git a/src/js_parser/function_identities.rs b/src/js_parser/function_identities.rs index 174a37eb3ad8..4c39eeb80947 100644 --- a/src/js_parser/function_identities.rs +++ b/src/js_parser/function_identities.rs @@ -98,7 +98,6 @@ impl FunctionIdentities { options.features.no_macros = true; options.features.top_level_await = kind == Text::Module; options.jsc_builtin_syntax = kind == Text::Builtin; - options.suppress_warnings_about_weird_code = true; let define = crate::Define::default(); let mut log = bun_ast::Log::init(); let parser = crate::Parser::init(options, &mut log, &source, &define, &arena).ok()?; diff --git a/src/js_parser/p.rs b/src/js_parser/p.rs index f980076379b9..3cde12f089e6 100644 --- a/src/js_parser/p.rs +++ b/src/js_parser/p.rs @@ -260,7 +260,6 @@ pub struct P<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> { pub(crate) allow_private_identifiers: bool, pub(crate) has_top_level_return: bool, - pub(crate) latest_return_had_semicolon: bool, pub(crate) has_import_meta: bool, pub(crate) has_es_module_syntax: bool, pub(crate) top_level_await_keyword: bun_ast::Range, @@ -9834,7 +9833,6 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O // ─── all remaining fields default ─── allow_private_identifiers: false, has_top_level_return: false, - latest_return_had_semicolon: false, has_import_meta: false, has_es_module_syntax: false, top_level_await_keyword: bun_ast::Range::NONE, diff --git a/src/js_parser/parse/mod.rs b/src/js_parser/parse/mod.rs index 8e3392db382a..141fd09b7ac1 100644 --- a/src/js_parser/parse/mod.rs +++ b/src/js_parser/parse/mod.rs @@ -1476,7 +1476,6 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O let mut opts = *_opts; let mut stmts = StmtList::new_in(p.arena); - let mut return_without_semicolon_start: i32 = -1; opts.lexical_decl = LexicalDecl::AllowAll; let mut is_directive_prologue = true; @@ -1541,30 +1540,6 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O if !skip { stmts.push(stmt); } - - // Warn about ASI and return statements. Here's an example of code with - // this problem: https://github.com/rollup/rollup/issues/3729 - if !p.options.suppress_warnings_about_weird_code { - let mut needs_check = true; - if let js_ast::stmt::Data::SReturn(ret) = &stmt.data { - if ret.value.is_none() && !p.latest_return_had_semicolon { - return_without_semicolon_start = stmt.loc.start; - needs_check = false; - } - } - - if needs_check && return_without_semicolon_start != -1 { - if let js_ast::stmt::Data::SExpr(_) = &stmt.data { - p.log().add_warning( - Some(p.source), - bun_ast::Loc { start: return_without_semicolon_start + 6 }, - b"The following expression is not returned because of an automatically-inserted semicolon", - ); - } - - return_without_semicolon_start = -1; - } - } } Ok(stmts) diff --git a/src/js_parser/parse/parse_entry.rs b/src/js_parser/parse/parse_entry.rs index 4fc84c1320b0..5e1c38a6628e 100644 --- a/src/js_parser/parse/parse_entry.rs +++ b/src/js_parser/parse/parse_entry.rs @@ -115,7 +115,6 @@ pub struct Options<'a> { pub ignore_dce_annotations: bool, pub preserve_unused_imports_ts: bool, pub use_define_for_class_fields: bool, - pub suppress_warnings_about_weird_code: bool, pub features: RuntimeFeatures, pub tree_shaking: bool, @@ -172,7 +171,6 @@ impl<'a> Default for Options<'a> { ignore_dce_annotations: false, preserve_unused_imports_ts: false, use_define_for_class_fields: true, - suppress_warnings_about_weird_code: true, features: RuntimeFeatures::default(), tree_shaking: false, bundle: false, @@ -223,7 +221,6 @@ impl<'a> Options<'a> { ignore_dce_annotations: self.ignore_dce_annotations, preserve_unused_imports_ts: self.preserve_unused_imports_ts, use_define_for_class_fields: self.use_define_for_class_fields, - suppress_warnings_about_weird_code: self.suppress_warnings_about_weird_code, features: RuntimeFeatures { react_fast_refresh: f.react_fast_refresh, react_compiler: f.react_compiler, @@ -330,7 +327,6 @@ impl<'a> Options<'a> { ignore_dce_annotations: false, preserve_unused_imports_ts: false, use_define_for_class_fields: true, - suppress_warnings_about_weird_code: true, features: RuntimeFeatures::default(), tree_shaking: false, bundle: false, diff --git a/src/js_parser/parse/parse_stmt.rs b/src/js_parser/parse/parse_stmt.rs index 5298b27df33d..7435c8a88bf7 100644 --- a/src/js_parser/parse/parse_stmt.rs +++ b/src/js_parser/parse/parse_stmt.rs @@ -762,7 +762,6 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O { value = Some(p.parse_expr(Level::Lowest)?); } - p.latest_return_had_semicolon = p.lexer.token == T::TSemicolon; p.lexer.expect_or_insert_semicolon()?; Ok(p.s(S::Return { value }, loc)) diff --git a/src/js_parser/parse/parse_suffix.rs b/src/js_parser/parse/parse_suffix.rs index 76c1603f3c60..623111c184b8 100644 --- a/src/js_parser/parse/parse_suffix.rs +++ b/src/js_parser/parse/parse_suffix.rs @@ -1392,14 +1392,6 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O return Ok(Continuation::Done); } - // Warn about "!a in b" instead of "!(a in b)" - if let ExprData::EUnary(unary) = &left.data { - if unary.op == OpCode::UnNot { - // TODO: - // p.log.addRangeWarning(source: ?Source, r: Range, text: string) - } - } - p.lexer.next()?; let loc = left.loc; let prev = *left; @@ -1420,16 +1412,6 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O return Ok(Continuation::Done); } - // Warn about "!a instanceof b" instead of "!(a instanceof b)". Here's an - // example of code with this problem: https://github.com/mrdoob/three.js/pull/11182. - if !p.options.suppress_warnings_about_weird_code { - if let ExprData::EUnary(unary) = &left.data { - if unary.op == OpCode::UnNot { - // TODO: - // p.log.addRangeWarning(source: ?Source, r: Range, text: string) - } - } - } p.lexer.next()?; let loc = left.loc; let prev = *left; diff --git a/src/runtime/cli/mod.rs b/src/runtime/cli/mod.rs index 1daeb90686a8..ddd4b7d2c87d 100644 --- a/src/runtime/cli/mod.rs +++ b/src/runtime/cli/mod.rs @@ -395,15 +395,10 @@ pub(crate) use cli as Cli; pub(crate) mod help_command { use super::*; - #[derive(Copy, Clone, PartialEq, Eq)] - pub(crate) enum Reason { - Explicit, - InvalidCommand, - } - #[cold] pub(crate) fn exec() -> crate::Result<()> { - exec_with_reason(Reason::Explicit) + print(false); + Global::exit(0); } // someone will get mad at me for this @@ -437,17 +432,14 @@ pub(crate) mod help_command { ]; const PACKAGES_TO_CREATE_FILLER: &[&str] = &["next-app", "vite", "astro", "svelte", "elysia"]; - /// Emits the `pretty!`/`pretty_error!` call directly instead of + /// Emits the `pretty!` call directly instead of /// expanding to a bare literal — `pretty!` captures its template as /// `$fmt:expr`, which is opaque to the `pretty_fmt!` proc-macro, so a /// nested `cli_helptext_fmt!()` inside `concat!()` would never be flattened. - /// Taking the printer macro (and per-reason prefix line) as parameters keeps - /// a single source of truth for the 35-line help body across both - /// `Reason::Explicit` (stdout) and `Reason::InvalidCommand` (stderr). /// The spacing between commands is intentional. macro_rules! print_cli_helptext { - ($printer:ident, $prefix:literal, $args:expr $(, $extra:expr)*) => { - $printer!( + ($prefix:literal, $args:expr $(, $extra:expr)*) => { + pretty!( concat!($prefix, "\ Usage: bun \\ [...flags] [...args] @@ -492,9 +484,7 @@ pub(crate) mod help_command { }; } - // Tag/Reason lack `ConstParamTy` in lower-tier crates, so `reason` is a - // runtime arg. - pub(crate) fn print_with_reason(reason: Reason, show_all_flags: bool) { + pub(crate) fn print(show_all_flags: bool) { let mut rand = bun_core::rand::DefaultPrng::init( u64::try_from(bun_core::time::milli_timestamp().max(0)).expect("int cast"), ); @@ -520,46 +510,25 @@ pub(crate) mod help_command { PACKAGES_TO_CREATE_FILLER[package_create_i], ); - match reason { - Reason::Explicit => { - print_cli_helptext!( - pretty, - "Bun is a fast JavaScript runtime, package manager, bundler, and test runner. ({})\n\n", - args, - Global::package_json_version_with_revision - ); - if show_all_flags { - pretty!("\nFlags:"); - bun_clap::simple_help_bun_top_level(arguments::AUTO_PARAMS); - pretty!( - "\n\n(more flags in bun install --help, bun test --help, and bun build --help)\n", - ); - } - pretty!( - "\nLearn more about Bun: https://bun.com/docs\n\ -Join our Discord community: https://bun.com/discord\n" - ); - } - Reason::InvalidCommand => { - print_cli_helptext!( - pretty_error, - "Uh-oh not sure what to do with that command.\n\n", - args - ); - } + print_cli_helptext!( + "Bun is a fast JavaScript runtime, package manager, bundler, and test runner. ({})\n\n", + args, + Global::package_json_version_with_revision + ); + if show_all_flags { + pretty!("\nFlags:"); + bun_clap::simple_help_bun_top_level(arguments::AUTO_PARAMS); + pretty!( + "\n\n(more flags in bun install --help, bun test --help, and bun build --help)\n", + ); } + pretty!( + "\nLearn more about Bun: https://bun.com/docs\n\ +Join our Discord community: https://bun.com/discord\n" + ); Output::flush(); } - - #[cold] - fn exec_with_reason(reason: Reason) -> ! { - print_with_reason(reason, false); - if reason == Reason::InvalidCommand { - Global::exit(1); - } - Global::exit(0); - } } pub(crate) use help_command as HelpCommand; @@ -1916,7 +1885,7 @@ To create a project with the official Next.js scaffolding tool, run // `{}` prints the raw markup. match cmd { Tag::AutoCommand | Tag::HelpCommand => { - HelpCommand::print_with_reason(HelpCommand::Reason::Explicit, show_all_flags); + HelpCommand::print(show_all_flags); } Tag::RunCommand | Tag::RunAsNodeCommand => { run_command::RunCommand::print_help(None); @@ -2257,7 +2226,7 @@ Full documentation is available at https://bun.com/docs/lint Tag::PackageManagerCommand => { pm_print_help(PmSubcommand::Pm); } - _ => HelpCommand::print_with_reason(HelpCommand::Reason::Explicit, false), + _ => HelpCommand::print(false), } } diff --git a/src/runtime/cli/pm_diff_normalize.rs b/src/runtime/cli/pm_diff_normalize.rs index 9331a6fea844..cffbffa0d284 100644 --- a/src/runtime/cli/pm_diff_normalize.rs +++ b/src/runtime/cli/pm_diff_normalize.rs @@ -218,7 +218,6 @@ fn parse_js<'a>( opts.features.trim_unused_imports = false; opts.features.minify_syntax = options.minify_syntax; opts.transform_only = true; - opts.suppress_warnings_about_weird_code = true; let define: &'a bun_js_parser::Define = arena.alloc(bun_js_parser::Define::default()); let mut log = bun_ast::Log::init(); let parser = bun_js_parser::Parser::init(opts, &mut log, source, define, arena).ok()?;