File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -806,14 +806,15 @@ def parse_number
806806 # Sometimes numbers are followed by a quote, which is garbage
807807 @scanner . getch if peek_char == '"'
808808
809- # Fix for Ruby < 3.4: "1." is not a valid float, so we append "0" to make it "1.0"
810- str_to_parse = scanned_str
811- "#{ str_to_parse } 0" if str_to_parse . end_with? ( '.' )
812-
813809 # Attempt to convert the string to the appropriate number type.
814810 # Use rescue to handle conversion errors gracefully, returning the original string.
815811 begin
816- if scanned_str . include? ( ',' )
812+ # Fix for Ruby < 3.4: "1." is not a valid float.
813+ # If it ends with '.', we strip the dot and force Float conversion
814+ # to ensure "1." becomes 1.0 (Float) instead of 1 (Integer).
815+ if scanned_str . end_with? ( '.' )
816+ Float ( scanned_str [ 0 ...-1 ] )
817+ elsif scanned_str . include? ( ',' )
817818 Float ( scanned_str . tr ( ',' , '.' ) )
818819 elsif scanned_str . match? ( /[.eE]/ )
819820 Float ( scanned_str )
You can’t perform that action at this time.
0 commit comments