Skip to content
Merged
6 changes: 3 additions & 3 deletions src/hk_compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "hk_scanner.h"
#include "hk_struct.h"
#include "hk_builtin.h"
#include "hk_utils.h"

#define MAX_CONSTANTS UINT8_MAX
#define MAX_VARIABLES UINT8_MAX
Expand Down Expand Up @@ -174,9 +175,8 @@ static inline double parse_double(compiler_t *comp)
{
scanner_t *scan = comp->scan;
token_t *tk = &scan->token;
errno = 0;
double result = strtod(tk->start, NULL);
if (errno == ERANGE)
double result;
if (!hk_double_from_chars(&result, tk->start))
syntax_error(comp->fn->name, scan->file->chars, tk->line, tk->col,
"floating point number `%.*s` out of range", tk->length, tk->start);
return result;
Expand Down