diff --git a/clarity/Cargo.toml b/clarity/Cargo.toml index cba9468313..74d49d2766 100644 --- a/clarity/Cargo.toml +++ b/clarity/Cargo.toml @@ -47,7 +47,7 @@ rstest_reuse = { version = "0.5.0" } serde_stacker = "0.1" [features] -default = ["rusqlite"] +default = ["devtools"] developer-mode = ["stacks_common/developer-mode", "clarity-types/developer-mode"] slog_json = ["stacks_common/slog_json"] rusqlite = ["stacks_common/rusqlite", "clarity-types/rusqlite", "dep:rusqlite"] diff --git a/clarity/src/vm/ast/mod.rs b/clarity/src/vm/ast/mod.rs index b09de172e6..4ebb7b2f7e 100644 --- a/clarity/src/vm/ast/mod.rs +++ b/clarity/src/vm/ast/mod.rs @@ -28,6 +28,7 @@ use stacks_common::types::StacksEpochId; use self::definition_sorter::DefinitionSorter; use self::errors::ParseResult; use self::expression_identifier::ExpressionIdentifier; +#[cfg(not(feature = "devtools"))] use self::parser::v1::parse as parse_v1; use self::parser::v2::parse as parse_v2; use self::stack_depth_checker::{StackDepthChecker, VaryStackDepthChecker}; @@ -58,12 +59,21 @@ pub fn parse( /// Parse a program based on which epoch is active fn parse_in_epoch( source_code: &str, - epoch_id: StacksEpochId, + // the epoch_id argument can be removed as part of #3662 (removing parser v1) + #[allow(unused_variables)] epoch_id: StacksEpochId, ) -> ParseResult> { - if epoch_id >= StacksEpochId::Epoch21 { + #[cfg(feature = "devtools")] + { parse_v2(source_code) - } else { - parse_v1(source_code) + } + + #[cfg(not(feature = "devtools"))] + { + if epoch_id >= StacksEpochId::Epoch21 { + parse_v2(source_code) + } else { + parse_v1(source_code) + } } } @@ -111,7 +121,8 @@ fn inner_build_ast( source_code: &str, cost_track: &mut T, clarity_version: ClarityVersion, - epoch: StacksEpochId, + // the epoch_id argument can be removed as part of #3662 (removing parser v1) + #[allow(unused_variables)] epoch: StacksEpochId, error_early: bool, ) -> ParseResult<(ContractAST, Vec, bool)> { let cost_err = match runtime_cost( @@ -124,9 +135,18 @@ fn inner_build_ast( _ => None, }; + #[cfg(feature = "devtools")] + let (pre_expressions, mut diagnostics, mut success) = if error_early { + let exprs = parse_v2(source_code)?; + (exprs, Vec::new(), true) + } else { + parser::v2::parse_collect_diagnostics(source_code) + }; + + #[cfg(not(feature = "devtools"))] let (pre_expressions, mut diagnostics, mut success) = if epoch >= StacksEpochId::Epoch21 { if error_early { - let exprs = parser::v2::parse(source_code)?; + let exprs = parse_v2(source_code)?; (exprs, Vec::new(), true) } else { parser::v2::parse_collect_diagnostics(source_code)