plasma
plasma copied to clipboard
Type error reported on wrong line.
func string_to_int(s : String) -> Int {
func loop(pos : StringPos, num : Int) -> Int {
var maybe_cp = strpos_next(pos)
match (maybe_cp) {
None -> {
// End of input.
return num
}
Some(var cp) -> {
var maybe_digit = codepoint_to_digit(cp)
match (maybe_digit) {
Some(var digit) -> {
return loop(strpos_forward(pos), num * 10 + digit)
}
None -> {
// Could make this function return a maybe.
Builtin.die!("Bad number")
return 0
}
}
}
}
}
return loop(string_begin(s))
}
The error should have been reported on the call to loop, not the creation.