File tree Expand file tree Collapse file tree 3 files changed +42
-2
lines changed Expand file tree Collapse file tree 3 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -1650,8 +1650,10 @@ absl::StatusOr<BValue> FunctionConverter::HandleForBody(
16501650
16511651 XLS_ASSIGN_OR_RETURN (BValue init, Use (node->init ()));
16521652 if (implicit_token_data_.has_value ()) {
1653- BValue activated = trip_count == 0 ? function_builder_->Literal (UBits (0 , 1 ))
1654- : implicit_token_data_->activated ;
1653+ BValue activated = trip_count == 0
1654+ ? function_builder_->Literal (UBits (0 , 1 ))
1655+ : implicit_token_data_->create_control_predicate ();
1656+
16551657 init = function_builder_->Tuple (
16561658 {implicit_token_data_->entry_token , activated, init});
16571659 }
Original file line number Diff line number Diff line change @@ -911,6 +911,16 @@ dslx_lang_test(
911911 test_ir_equivalence = False ,
912912)
913913
914+ dslx_lang_test (
915+ name = "assert_in_for_under_inactive_conditional" ,
916+ compare = "interpreter" ,
917+ # Don't convert to IR because we want to compare the IR interpreter and
918+ # DSL interpreter. convert_to_ir=True disables comparison.
919+ convert_to_ir = False ,
920+ # IR asserts are software-only; skip z3 equivalence.
921+ test_ir_equivalence = False ,
922+ )
923+
914924dslx_lang_test (
915925 name = "quickcheck_fn_with_fail" ,
916926 # Primarily a #[quickcheck] function.
Original file line number Diff line number Diff line change 1+ // Copyright 2025 The XLS Authors
2+ //
3+ // Licensed under the Apache License, Version 2.0 (the "License");
4+ // you may not use this file except in compliance with the License.
5+ // You may obtain a copy of the License at
6+ //
7+ // http://www.apache.org/licenses/LICENSE-2.0
8+ //
9+ // Unless required by applicable law or agreed to in writing, software
10+ // distributed under the License is distributed on an "AS IS" BASIS,
11+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ // See the License for the specific language governing permissions and
13+ // limitations under the License.
14+
15+ fn main () -> () { () }
16+
17+ fn bar () -> () { assert !(false , " Should not happen." ); }
18+
19+ fn foo (x: bool ) -> () {
20+ if x {
21+ for (_, ()) in u32 :0 ..u32 :4 {
22+ bar ()
23+ }(())
24+ }
25+ }
26+
27+ #[test]
28+ fn test_main_no_assert_when_false () { foo (false ) }
You can’t perform that action at this time.
0 commit comments