This commit is contained in:
blueloveTH 2023-10-11 14:46:54 +08:00
parent b26dbf08cc
commit dbf7dfe7da
2 changed files with 3 additions and 3 deletions

View File

@ -292,12 +292,12 @@ static bool is_unicode_Lo_char(uint32_t c) {
char* p_end; char* p_end;
try{ try{
float_out = std::strtod(text.begin(), &p_end); float_out = std::strtod(text.data(), &p_end);
}catch(...){ }catch(...){
SyntaxError("invalid number literal"); SyntaxError("invalid number literal");
} }
if(p_end == text.end()){ if(p_end == text.data() + text.size()){
add_token(TK("@num"), (f64)float_out); add_token(TK("@num"), (f64)float_out);
return; return;
} }

View File

@ -502,7 +502,7 @@ void init_builtins(VM* _vm) {
double float_out; double float_out;
char* p_end; char* p_end;
try{ try{
float_out = std::strtod(s.begin(), &p_end); float_out = std::strtod(s.data, &p_end);
PK_ASSERT(p_end == s.end()); PK_ASSERT(p_end == s.end());
}catch(...){ }catch(...){
vm->ValueError("invalid literal for float(): " + s.escape()); vm->ValueError("invalid literal for float(): " + s.escape());