Browse Source

parse e+x floats in macros (closes #2558)

Simon Krajewski 11 years ago
parent
commit
aeb94e5455
2 changed files with 14 additions and 1 deletions
  1. 1 1
      interp.ml
  2. 13 0
      tests/unit/issues/Issue2558.hx

+ 1 - 1
interp.ml

@@ -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)

+ 13 - 0
tests/unit/issues/Issue2558.hx

@@ -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};
+	}
+}