[ruby/prism] Ignore other ERANGE errors for floats
https://github.com/ruby/prism/commit/4267161ca7
This commit is contained in:
parent
4016535404
commit
a154ea0c91
@ -10,6 +10,7 @@
|
||||
#define PRISM_DEFINES_H
|
||||
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
@ -113,4 +114,15 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* isinf on Windows is defined as accepting a float, but on POSIX systems it
|
||||
* accepts a float, a double, or a long double. We want to mirror this behavior
|
||||
* on windows.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
# include <float.h>
|
||||
# undef isinf
|
||||
# define isinf(x) (sizeof(x) == sizeof(float) ? !_finitef(x) : !_finite(x))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -3181,7 +3181,7 @@ pm_double_parse(pm_parser_t *parser, const pm_token_t *token) {
|
||||
|
||||
// If errno is set, then it should only be ERANGE. At this point we need to
|
||||
// check if it's infinity (it should be).
|
||||
if (errno == ERANGE) {
|
||||
if (errno == ERANGE && isinf(value)) {
|
||||
int warn_width;
|
||||
const char *ellipsis;
|
||||
|
||||
@ -3194,7 +3194,7 @@ pm_double_parse(pm_parser_t *parser, const pm_token_t *token) {
|
||||
}
|
||||
|
||||
pm_diagnostic_list_append_format(&parser->warning_list, token->start, token->end, PM_WARN_FLOAT_OUT_OF_RANGE, warn_width, (const char *) token->start, ellipsis);
|
||||
value = (value < 0x0) ? -HUGE_VAL : HUGE_VAL;
|
||||
value = (value < 0.0) ? -HUGE_VAL : HUGE_VAL;
|
||||
}
|
||||
|
||||
// Finally we can free the buffer and return the value.
|
||||
|
Loading…
x
Reference in New Issue
Block a user