Segfault
moon-chilled opened this issue · 1 comments
moon-chilled commented
The compiler segfaults with this code:
fun hex: Str str -> i32
mut ret: i32 = 0
mut i: usz = 0
while i < str.len do
ret *= 16
ret += match str#i with
| '0' .. '9' -> str#i - '0'
| 'a' .. 'f' -> str#i - 'a'
| 'A' .. 'F' -> str#i - 'A'
i += 1
ret
let a = hex "04"
jfecher commented
This appears to be from the deprecated name: type
syntax. I tested this with my local version (on the jit branch) and it is already fixed there. I think I will hold off on this fix until jit is merged into master.
As a side note, range based patterns are not implemented yet so you will have to manually check with if statements for what your are doing in the time being. eg.
while i < str.len do
ret *= 16
if i32(str#i) in i32 '0' .. i32 '9' then ret += str#i - u8 '0'
...
Because ranges are only defined for integers and not c8
at the moment it may be easier to just manually compare
if '0' <= str#i and str#i <= '9' then ...