Skip to content

Commit e6ad733

Browse files
committed
Use more specific return type
1 parent 8708e5b commit e6ad733

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

mypyc/primitives/str_ops.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
list_rprimitive,
1717
object_rprimitive,
1818
pointer_rprimitive,
19+
short_int_rprimitive,
1920
str_rprimitive,
2021
tuple_rprimitive,
2122
)
@@ -536,7 +537,7 @@
536537
str_get_item_unsafe_as_int_op = custom_primitive_op(
537538
name="str_get_item_unsafe_as_int",
538539
arg_types=[str_rprimitive, int64_rprimitive],
539-
return_type=int_rprimitive,
540+
return_type=short_int_rprimitive,
540541
c_function_name="CPyStr_GetItemUnsafeAsInt",
541542
error_kind=ERR_NEVER,
542543
dependencies=[STR_EXTRA_OPS],

mypyc/test-data/irbuild-str.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ def ord_str_index(s, i):
525525
r5 :: c_ptr
526526
r6, r7 :: i64
527527
r8, r9 :: bool
528-
r10 :: int
528+
r10 :: short_int
529529
L0:
530530
r0 = i & 1
531531
r1 = r0 == 0
@@ -554,7 +554,7 @@ def ord_str_index_i64(s, i):
554554
s :: str
555555
i, r0 :: i64
556556
r1, r2 :: bool
557-
r3 :: int
557+
r3 :: short_int
558558
L0:
559559
r0 = CPyStr_AdjustIndex(s, i)
560560
r1 = CPyStr_RangeCheck(s, r0)

0 commit comments

Comments
 (0)