@@ -27,9 +27,10 @@ impl ComplexWord for Let {
2727
2828 check_args ! ( generator, builder, 2 , args_len, ArgumentCountCheck :: AtLeast ) ;
2929
30- self . charge ( generator, builder, args_len as u32 ) ?;
31-
3230 let bindings = args. get_list ( 0 ) ?;
31+ let bindings_len = bindings. len ( ) ;
32+
33+ self . charge ( generator, builder, bindings_len as u32 ) ?;
3334
3435 // Save the current named locals
3536 let saved_locals = generator. bindings . clone ( ) ;
@@ -89,9 +90,12 @@ impl ComplexWord for Let {
8990
9091#[ cfg( test) ]
9192mod tests {
92- use clarity:: vm:: Value ;
93+ use clarity:: { types :: StacksEpochId , vm:: Value } ;
9394
94- use crate :: tools:: { crosscheck, crosscheck_compare_only, crosscheck_expect_failure, evaluate} ;
95+ use crate :: tools:: {
96+ crosscheck, crosscheck_compare_only, crosscheck_expect_failure, crosscheck_with_epoch,
97+ evaluate,
98+ } ;
9599
96100 #[ cfg( feature = "test-clarity-v1" ) ]
97101 mod clarity_v1 {
@@ -132,6 +136,28 @@ mod tests {
132136 crosscheck_expect_failure ( & format ! ( "{ERR} (test)" ) ) ;
133137 }
134138
139+ #[ test]
140+ fn clar_let_cost ( ) {
141+ const SNIPPET_LET : & str = r#"
142+ (let ((a u1) (b u2))
143+ (+ a b)
144+ )
145+ "# ;
146+ const SNIPPET_NO_LET : & str = r#"
147+ (+ u1 u2)
148+ "# ;
149+ // crosscheck_with_epoch(
150+ // SNIPPET_LET,
151+ // Ok(Some(Value::UInt(3))),
152+ // StacksEpochId::Epoch20,
153+ // );
154+ crosscheck_with_epoch (
155+ SNIPPET_NO_LET ,
156+ Ok ( Some ( Value :: UInt ( 3 ) ) ) ,
157+ StacksEpochId :: Epoch31 ,
158+ ) ;
159+ }
160+
135161 #[ test]
136162 fn clar_let_disallow_user_defined_names ( ) {
137163 // It's not allowed to use names of user-defined functions as bindings
0 commit comments