Stop single digit strings from throwing an IndexError on `parse` (#59)

This commit is contained in:
Luke Parker 2018-08-05 16:47:05 -05:00 committed by Mamy Ratsimbazafy
parent 406f1aa317
commit d6435b37ef
1 changed files with 3 additions and 0 deletions

View File

@ -90,6 +90,9 @@ func skipPrefixes(current_idx: var int, str: string, base: range[2..16]) {.inlin
## Returns the index of the first meaningful char in `hexStr` by skipping
## "0x" prefix
if str.len < 2:
return
assert current_idx == 0, "skipPrefixes only works for prefixes (position 0 and 1 of the string)"
if str[0] == '0':
if str[1] in {'x', 'X'}: