Skip to content

Commit 33ff40f

Browse files
committed
Merge pull request #12023 from ScottPJones/spj/fixbits
Fix problem with bitstype when N doesn't fit in 32-bits
2 parents abe0449 + 74b4ac6 commit 33ff40f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/interpreter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, size_t nl, size_t ng
371371
vnb = eval(args[2], locals, nl, ngensym);
372372
if (!jl_is_long(vnb))
373373
jl_errorf("invalid declaration of bits type %s", ((jl_sym_t*)name)->name);
374-
int32_t nb = jl_unbox_long(vnb);
374+
ssize_t nb = jl_unbox_long(vnb);
375375
if (nb < 1 || nb>=(1<<23) || (nb&7) != 0)
376376
jl_errorf("invalid number of bits in type %s",
377377
((jl_sym_t*)name)->name);

test/core.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3114,3 +3114,8 @@ end
31143114
const DATE12003 = DateTime(1917,1,1)
31153115
failure12003(dt=DATE12003) = Dates.year(dt)
31163116
@test isa(failure12003(), Integer)
3117+
3118+
# #12023 Test error checking in bitstype
3119+
@test_throws ErrorException bitstype 0 SPJa12023
3120+
@test_throws ErrorException bitstype 4294967312 SPJb12023
3121+
@test_throws ErrorException bitstype -4294967280 SPJc12023

0 commit comments

Comments
 (0)