From 89042585ae18bf64f38f45429380a161a99a49e3 Mon Sep 17 00:00:00 2001 From: Hugo C <235113615+hugo-stacks@users.noreply.github.com> Date: Tue, 16 Dec 2025 19:17:25 +0100 Subject: [PATCH 1/4] feat: force parser v2 with devtools flag --- clarity/src/vm/ast/mod.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/clarity/src/vm/ast/mod.rs b/clarity/src/vm/ast/mod.rs index b09de172e6..f4a15bbaa3 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}; @@ -60,6 +61,10 @@ fn parse_in_epoch( source_code: &str, epoch_id: StacksEpochId, ) -> ParseResult> { + #[cfg(feature = "devtools")] + return parse_v2(source_code); + + #[cfg(not(feature = "devtools"))] if epoch_id >= StacksEpochId::Epoch21 { parse_v2(source_code) } else { @@ -124,9 +129,19 @@ 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) From ead79b76fa7f89ff4cea1a0bf06fb8ab7c1a633d Mon Sep 17 00:00:00 2001 From: Hugo C <235113615+hugo-stacks@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:51:39 +0100 Subject: [PATCH 2/4] refactor: address review --- clarity/src/vm/ast/mod.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/clarity/src/vm/ast/mod.rs b/clarity/src/vm/ast/mod.rs index f4a15bbaa3..7051fb3dd1 100644 --- a/clarity/src/vm/ast/mod.rs +++ b/clarity/src/vm/ast/mod.rs @@ -62,13 +62,17 @@ fn parse_in_epoch( epoch_id: StacksEpochId, ) -> ParseResult> { #[cfg(feature = "devtools")] - return parse_v2(source_code); + { + parse_v2(source_code) + } #[cfg(not(feature = "devtools"))] - if epoch_id >= StacksEpochId::Epoch21 { - parse_v2(source_code) - } else { - parse_v1(source_code) + { + if epoch_id >= StacksEpochId::Epoch21 { + parse_v2(source_code) + } else { + parse_v1(source_code) + } } } From 457b6036df3f20d5862b90c6a97e2b6efebe7cbc Mon Sep 17 00:00:00 2001 From: Hugo C <235113615+hugo-stacks@users.noreply.github.com> Date: Fri, 19 Dec 2025 10:38:19 +0100 Subject: [PATCH 3/4] refactor: fix clippy and fmt --- clarity/Cargo.toml | 2 +- clarity/src/vm/ast/mod.rs | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) 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 7051fb3dd1..bf77db0b2a 100644 --- a/clarity/src/vm/ast/mod.rs +++ b/clarity/src/vm/ast/mod.rs @@ -59,20 +59,22 @@ pub fn parse( /// Parse a program based on which epoch is active fn parse_in_epoch( source_code: &str, + #[cfg(feature = "devtools")] + #[allow(unused_variables)] epoch_id: StacksEpochId, ) -> ParseResult> { #[cfg(feature = "devtools")] { - parse_v2(source_code) + parse_v2(source_code) } #[cfg(not(feature = "devtools"))] { - if epoch_id >= StacksEpochId::Epoch21 { - parse_v2(source_code) - } else { - parse_v1(source_code) - } + if epoch_id >= StacksEpochId::Epoch21 { + parse_v2(source_code) + } else { + parse_v1(source_code) + } } } @@ -120,6 +122,8 @@ fn inner_build_ast( source_code: &str, cost_track: &mut T, clarity_version: ClarityVersion, + #[cfg(feature = "devtools")] + #[allow(unused_variables)] epoch: StacksEpochId, error_early: bool, ) -> ParseResult<(ContractAST, Vec, bool)> { @@ -133,7 +137,6 @@ fn inner_build_ast( _ => None, }; - #[cfg(feature = "devtools")] let (pre_expressions, mut diagnostics, mut success) = if error_early { let exprs = parse_v2(source_code)?; From aadeb35a1cfc69bcb2e4ad664102009313b246c9 Mon Sep 17 00:00:00 2001 From: Hugo C <235113615+hugo-stacks@users.noreply.github.com> Date: Fri, 19 Dec 2025 16:48:56 +0100 Subject: [PATCH 4/4] fix: epoch_id argument handling --- clarity/src/vm/ast/mod.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/clarity/src/vm/ast/mod.rs b/clarity/src/vm/ast/mod.rs index bf77db0b2a..4ebb7b2f7e 100644 --- a/clarity/src/vm/ast/mod.rs +++ b/clarity/src/vm/ast/mod.rs @@ -59,9 +59,8 @@ pub fn parse( /// Parse a program based on which epoch is active fn parse_in_epoch( source_code: &str, - #[cfg(feature = "devtools")] - #[allow(unused_variables)] - epoch_id: StacksEpochId, + // the epoch_id argument can be removed as part of #3662 (removing parser v1) + #[allow(unused_variables)] epoch_id: StacksEpochId, ) -> ParseResult> { #[cfg(feature = "devtools")] { @@ -122,9 +121,8 @@ fn inner_build_ast( source_code: &str, cost_track: &mut T, clarity_version: ClarityVersion, - #[cfg(feature = "devtools")] - #[allow(unused_variables)] - 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(