diff --git a/lib/mp-readline/readline.c b/lib/mp-readline/readline.c
index 4b987513671231bd7900b6f8a6a473283cc6e5fe..5b35c8660adcb64134cd8a68b4623f312e32b5c5 100644
--- a/lib/mp-readline/readline.c
+++ b/lib/mp-readline/readline.c
@@ -188,17 +188,17 @@ int readline_process_char(int c) {
         } else if (c == 9) {
             // tab magic
             const char *compl_str;
-            mp_uint_t compl_len = mp_repl_autocomplete(rl.line->buf + rl.orig_line_len, rl.cursor_pos - rl.orig_line_len, &mp_plat_print, &compl_str);
+            size_t compl_len = mp_repl_autocomplete(rl.line->buf + rl.orig_line_len, rl.cursor_pos - rl.orig_line_len, &mp_plat_print, &compl_str);
             if (compl_len == 0) {
                 // no match
-            } else if (compl_len == (mp_uint_t)(-1)) {
+            } else if (compl_len == (size_t)(-1)) {
                 // many matches
                 mp_hal_stdout_tx_str(rl.prompt);
                 mp_hal_stdout_tx_strn(rl.line->buf + rl.orig_line_len, rl.cursor_pos - rl.orig_line_len);
                 redraw_from_cursor = true;
             } else {
                 // one match
-                for (mp_uint_t i = 0; i < compl_len; ++i) {
+                for (size_t i = 0; i < compl_len; ++i) {
                     vstr_ins_byte(rl.line, rl.cursor_pos + i, *compl_str++);
                 }
                 // set redraw parameters
diff --git a/py/repl.c b/py/repl.c
index 6d8f7cca465c62cfe4307c3c91004ee9ccb36648..8e55eb017dad718835a5809e3a7ae85d8a614f0a 100644
--- a/py/repl.c
+++ b/py/repl.c
@@ -32,7 +32,7 @@
 #if MICROPY_HELPER_REPL
 
 STATIC bool str_startswith_word(const char *str, const char *head) {
-    mp_uint_t i;
+    size_t i;
     for (i = 0; str[i] && head[i]; i++) {
         if (str[i] != head[i]) {
             return false;
@@ -124,7 +124,7 @@ bool mp_repl_continue_with_input(const char *input) {
     return false;
 }
 
-mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t *print, const char **compl_str) {
+size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print, const char **compl_str) {
     // scan backwards to find start of "a.b.c" chain
     const char *org_str = str;
     const char *top = str + len;
@@ -145,13 +145,13 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
         while (str < top && *str != '.') {
             ++str;
         }
-        mp_uint_t s_len = str - s_start;
+        size_t s_len = str - s_start;
 
         if (str < top) {
             // a complete word, lookup in current dict
 
             mp_obj_t obj = MP_OBJ_NULL;
-            for (mp_uint_t i = 0; i < dict->map.alloc; i++) {
+            for (size_t i = 0; i < dict->map.alloc; i++) {
                 if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) {
                     size_t d_len;
                     const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len);
@@ -194,8 +194,8 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
             // look for matches
             int n_found = 0;
             const char *match_str = NULL;
-            mp_uint_t match_len = 0;
-            for (mp_uint_t i = 0; i < dict->map.alloc; i++) {
+            size_t match_len = 0;
+            for (size_t i = 0; i < dict->map.alloc; i++) {
                 if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) {
                     size_t d_len;
                     const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len);
@@ -206,7 +206,7 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
                         } else {
                             // search for longest common prefix of match_str and d_str
                             // (assumes these strings are null-terminated)
-                            for (mp_uint_t j = s_len; j <= match_len && j <= d_len; ++j) {
+                            for (size_t j = s_len; j <= match_len && j <= d_len; ++j) {
                                 if (match_str[j] != d_str[j]) {
                                     match_len = j;
                                     break;
@@ -245,7 +245,7 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
             #define MAX_LINE_LEN  (4 * WORD_SLOT_LEN)
 
             int line_len = MAX_LINE_LEN; // force a newline for first word
-            for (mp_uint_t i = 0; i < dict->map.alloc; i++) {
+            for (size_t i = 0; i < dict->map.alloc; i++) {
                 if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) {
                     size_t d_len;
                     const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len);
@@ -270,7 +270,7 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
             }
             mp_print_str(print, "\n");
 
-            return (mp_uint_t)(-1); // indicate many matches
+            return (size_t)(-1); // indicate many matches
         }
     }
 }
diff --git a/py/repl.h b/py/repl.h
index c34a5b86924b31724776ebd5768db2ab8ce4ac23..048b0de0f91b2ab210ea974af0fbd9baefadb8fe 100644
--- a/py/repl.h
+++ b/py/repl.h
@@ -32,7 +32,7 @@
 
 #if MICROPY_HELPER_REPL
 bool mp_repl_continue_with_input(const char *input);
-mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t *print, const char **compl_str);
+size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print, const char **compl_str);
 #endif
 
 #endif // __MICROPY_INCLUDED_PY_REPL_H__
diff --git a/unix/coverage.c b/unix/coverage.c
index 8391cd08be12d8a7b8c1a71d335dd84b834200b1..4a9ab194bb4b837092c7e18b65e8f78d4f969cb9 100644
--- a/unix/coverage.c
+++ b/unix/coverage.c
@@ -190,7 +190,7 @@ STATIC mp_obj_t extra_coverage(void) {
         mp_printf(&mp_plat_print, "# repl\n");
 
         const char *str;
-        mp_uint_t len = mp_repl_autocomplete("__n", 3, &mp_plat_print, &str);
+        size_t len = mp_repl_autocomplete("__n", 3, &mp_plat_print, &str);
         mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);
 
         mp_store_global(MP_QSTR_sys, mp_import_name(MP_QSTR_sys, mp_const_none, MP_OBJ_NEW_SMALL_INT(0)));