File tree 6 files changed +20
-0
lines changed
6 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ cc_library(
93
93
":parametric_env" ,
94
94
":parametric_instantiator" ,
95
95
":type_and_parametric_env" ,
96
+ ":type_info" ,
96
97
":unwrap_meta_type" ,
97
98
"@com_google_absl//absl/algorithm:container" ,
98
99
"@com_google_absl//absl/cleanup" ,
Original file line number Diff line number Diff line change 60
60
#include " xls/dslx/type_system/parametric_env.h"
61
61
#include " xls/dslx/type_system/parametric_instantiator.h"
62
62
#include " xls/dslx/type_system/type_and_parametric_env.h"
63
+ #include " xls/dslx/type_system/type_info.h"
63
64
#include " xls/dslx/type_system/unwrap_meta_type.h"
64
65
#include " xls/dslx/warning_kind.h"
65
66
#include " xls/ir/bits.h"
Original file line number Diff line number Diff line change 20
20
21
21
#include " absl/status/statusor.h"
22
22
#include " absl/types/span.h"
23
+ #include " xls/dslx/frontend/ast.h"
23
24
#include " xls/dslx/frontend/ast_node.h"
24
25
#include " xls/dslx/type_system/concrete_type.h"
25
26
#include " xls/dslx/type_system/deduce_ctx.h"
Original file line number Diff line number Diff line change @@ -405,6 +405,16 @@ fn main(p: u32) -> () {
405
405
HasSubstr (" const_assert! expression is not constexpr" )));
406
406
}
407
407
408
+ TEST (TypecheckErrorTest, FitsInTypeSN0) {
409
+ EXPECT_THAT (Typecheck (R"(
410
+ fn main() -> sN[0] {
411
+ sN[0]:0xffff_ffff_ffff_ffff_ffff
412
+ })" ),
413
+ StatusIs (absl::StatusCode::kInvalidArgument ,
414
+ HasSubstr (" Value '0xffff_ffff_ffff_ffff_ffff' does not "
415
+ " fit in the bitwidth of a sN[0]" )));
416
+ }
417
+
408
418
TEST (TypecheckTest, ForBuiltinInBody) {
409
419
XLS_EXPECT_OK (Typecheck (R"(
410
420
fn f() -> u32 {
Original file line number Diff line number Diff line change @@ -75,11 +75,17 @@ Bits Bits::AllOnes(int64_t bit_count) {
75
75
76
76
/* static */
77
77
Bits Bits::MaxSigned (int64_t bit_count) {
78
+ if (bit_count == 0 ) {
79
+ return SBits (0 , 0 );
80
+ }
78
81
return Bits::AllOnes (bit_count).UpdateWithSet (bit_count - 1 , false );
79
82
}
80
83
81
84
/* static */
82
85
Bits Bits::MinSigned (int64_t bit_count) {
86
+ if (bit_count == 0 ) {
87
+ return SBits (0 , 0 );
88
+ }
83
89
return Bits::PowerOfTwo (bit_count - 1 , bit_count);
84
90
}
85
91
Original file line number Diff line number Diff line change 21
21
#include < vector>
22
22
23
23
#include " absl/status/statusor.h"
24
+ #include " absl/types/span.h"
24
25
#include " xls/common/logging/logging.h"
25
26
#include " xls/common/math_util.h"
26
27
#include " xls/data_structures/inline_bitmap.h"
You can’t perform that action at this time.
0 commit comments