@@ -68,8 +68,6 @@ fn parse_in_epoch(
68
68
) -> ParseResult < Vec < PreSymbolicExpression > > {
69
69
if epoch_id >= StacksEpochId :: Epoch21 {
70
70
parse_v2 ( source_code)
71
- } else if ast_rules == ASTRules :: Typical {
72
- parse_v1_no_stack_limit ( source_code)
73
71
} else {
74
72
parse_v1 ( source_code)
75
73
}
@@ -100,23 +98,13 @@ pub fn build_ast_with_rules<T: CostTracker>(
100
98
epoch : StacksEpochId ,
101
99
ruleset : ASTRules ,
102
100
) -> ParseResult < ContractAST > {
103
- match ruleset {
104
- // After epoch 2.1, prechecking the size is required
105
- ASTRules :: Typical if epoch < StacksEpochId :: Epoch21 => build_ast_typical (
106
- contract_identifier,
107
- source_code,
108
- cost_track,
109
- clarity_version,
110
- epoch,
111
- ) ,
112
- _ => build_ast_precheck_size (
113
- contract_identifier,
114
- source_code,
115
- cost_track,
116
- clarity_version,
117
- epoch,
118
- ) ,
119
- }
101
+ build_ast_precheck_size (
102
+ contract_identifier,
103
+ source_code,
104
+ cost_track,
105
+ clarity_version,
106
+ epoch,
107
+ )
120
108
}
121
109
122
110
/// Build an AST with the typical rules
@@ -133,7 +121,7 @@ fn build_ast_typical<T: CostTracker>(
133
121
cost_track,
134
122
clarity_version,
135
123
epoch,
136
- ASTRules :: Typical ,
124
+ ASTRules :: PrecheckSize ,
137
125
true ,
138
126
) ?;
139
127
Ok ( contract)
@@ -190,10 +178,7 @@ fn inner_build_ast<T: CostTracker>(
190
178
parser:: v2:: parse_collect_diagnostics ( source_code)
191
179
}
192
180
} else {
193
- let parse_result = match ast_rules {
194
- ASTRules :: Typical => parse_v1_no_stack_limit ( source_code) ,
195
- ASTRules :: PrecheckSize => parse_v1 ( source_code) ,
196
- } ;
181
+ let parse_result = parse_v1 ( source_code) ;
197
182
match parse_result {
198
183
Ok ( pre_expressions) => ( pre_expressions, vec ! [ ] , true ) ,
199
184
Err ( error) if error_early => return Err ( error) ,
@@ -223,16 +208,14 @@ fn inner_build_ast<T: CostTracker>(
223
208
_ => ( ) ,
224
209
}
225
210
226
- if ast_rules != ASTRules :: Typical {
227
- // run extra stack-depth pass for tuples
228
- match VaryStackDepthChecker :: run_pass ( & mut contract_ast, clarity_version) {
229
- Err ( e) if error_early => return Err ( e) ,
230
- Err ( e) => {
231
- diagnostics. push ( e. diagnostic ) ;
232
- success = false ;
233
- }
234
- _ => ( ) ,
211
+ // run extra stack-depth pass for tuples
212
+ match VaryStackDepthChecker :: run_pass ( & mut contract_ast, clarity_version) {
213
+ Err ( e) if error_early => return Err ( e) ,
214
+ Err ( e) => {
215
+ diagnostics. push ( e. diagnostic ) ;
216
+ success = false ;
235
217
}
218
+ _ => ( ) ,
236
219
}
237
220
238
221
match ExpressionIdentifier :: run_pre_expression_pass ( & mut contract_ast, clarity_version) {
@@ -404,7 +387,7 @@ mod test {
404
387
& mut cost_track,
405
388
clarity_version,
406
389
StacksEpochId :: Epoch2_05 ,
407
- ASTRules :: Typical ,
390
+ ASTRules :: PrecheckSize ,
408
391
)
409
392
. expect_err ( "Contract should error in parsing" ) ;
410
393
@@ -441,18 +424,6 @@ mod test {
441
424
assert_eq ! ( expected_list_cost_state, cost_track) ;
442
425
443
426
// you cannot do the same for tuples!
444
- // in ASTRules::Typical, this passes
445
- let mut cost_track = UnitTestTracker :: new ( ) ;
446
- let _ = build_ast_with_rules (
447
- & QualifiedContractIdentifier :: transient ( ) ,
448
- & exceeds_stack_depth_tuple,
449
- & mut cost_track,
450
- clarity_version,
451
- StacksEpochId :: Epoch2_05 ,
452
- ASTRules :: Typical ,
453
- )
454
- . expect ( "Contract should parse with ASTRules::Typical" ) ;
455
-
456
427
// this actually won't even error without
457
428
// the VaryStackDepthChecker changes.
458
429
let mut cost_track = UnitTestTracker :: new ( ) ;
@@ -498,29 +469,6 @@ mod test {
498
469
")" . repeat( stack_limit + 1 )
499
470
) ;
500
471
501
- // with old rules, this is just ExpressionStackDepthTooDeep
502
- let mut cost_track = UnitTestTracker :: new ( ) ;
503
- let err = build_ast_with_rules (
504
- & QualifiedContractIdentifier :: transient ( ) ,
505
- & exceeds_stack_depth_list,
506
- & mut cost_track,
507
- * clarity_version,
508
- StacksEpochId :: Epoch21 ,
509
- ASTRules :: Typical ,
510
- )
511
- . expect_err ( "Contract should error in parsing" ) ;
512
-
513
- let expected_err = ParseErrors :: ExpressionStackDepthTooDeep ;
514
- let expected_list_cost_state = UnitTestTracker {
515
- invoked_functions : vec ! [ ( ClarityCostFunction :: AstParse , vec![ 500 ] ) ] ,
516
- invocation_count : 1 ,
517
- cost_addition_count : 1 ,
518
- } ;
519
-
520
- assert_eq ! ( & expected_err, & err. err) ;
521
- assert_eq ! ( expected_list_cost_state, cost_track) ;
522
-
523
- // in 2.1, this is still ExpressionStackDepthTooDeep
524
472
let mut cost_track = UnitTestTracker :: new ( ) ;
525
473
let err = build_ast_with_rules (
526
474
& QualifiedContractIdentifier :: transient ( ) ,
@@ -542,29 +490,6 @@ mod test {
542
490
assert_eq ! ( & expected_err, & err. err) ;
543
491
assert_eq ! ( expected_list_cost_state, cost_track) ;
544
492
545
- // in 2.1, ASTRules::Typical is ignored -- this still fails to parse
546
- let mut cost_track = UnitTestTracker :: new ( ) ;
547
- let _ = build_ast_with_rules (
548
- & QualifiedContractIdentifier :: transient ( ) ,
549
- & exceeds_stack_depth_tuple,
550
- & mut cost_track,
551
- * clarity_version,
552
- StacksEpochId :: Epoch21 ,
553
- ASTRules :: Typical ,
554
- )
555
- . expect_err ( "Contract should error in parsing" ) ;
556
-
557
- let expected_err = ParseErrors :: ExpressionStackDepthTooDeep ;
558
- let expected_list_cost_state = UnitTestTracker {
559
- invoked_functions : vec ! [ ( ClarityCostFunction :: AstParse , vec![ 571 ] ) ] ,
560
- invocation_count : 1 ,
561
- cost_addition_count : 1 ,
562
- } ;
563
-
564
- assert_eq ! ( & expected_err, & err. err) ;
565
- assert_eq ! ( expected_list_cost_state, cost_track) ;
566
-
567
- // in 2.1, ASTRules::PrecheckSize is still ignored -- this still fails to parse
568
493
let mut cost_track = UnitTestTracker :: new ( ) ;
569
494
let err = build_ast_with_rules (
570
495
& QualifiedContractIdentifier :: transient ( ) ,
0 commit comments