Skip to content

Commit

Permalink
parse e+x floats in macros (closes HaxeFoundation#2558)
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Feb 24, 2014
1 parent ab8778b commit aeb94e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion interp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ let parse_float s =
if i = String.length s then (if sp = 0 then s else String.sub s sp (i - sp)) else
match String.unsafe_get s i with
| ' ' when sp = i -> loop (sp + 1) (i + 1)
| '0'..'9' | '-' | 'e' | 'E' | '.' -> loop sp (i + 1)
| '0'..'9' | '-' | '+' | 'e' | 'E' | '.' -> loop sp (i + 1)
| _ -> String.sub s sp (i - sp)
in
float_of_string (loop 0 0)
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/issues/Issue2558.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package unit.issues;
import unit.Test;

class Issue2558 extends Test {
function test() {
feq(10, parse("1e+1"));
}

macro static function parse(s:String) {
var f = Std.parseFloat(s);
return macro $v{f};
}
}

0 comments on commit aeb94e5

Please sign in to comment.