@@ -5,6 +5,7 @@
jvm : fixed equality checks for `Null<Float>` and `Null<Int>` (#9897)
hl : fixed crash if a thread finishes without invoking `sendMessage`/`readMessage` (#9920)
php : fixed local vars with certain names (_SERVER, _GET etc) overriding super global values (#9924)
+ macro : added return type hint to haxe.macro.MacroStringTools.formatString (#9928)
2020-09-11 4.1.4:
@@ -39,7 +39,7 @@ class MacroStringTools {
The returned expression is a concatenation of string parts and escaped
elements.
**/
- static public function formatString(s:String, pos:Position) {
+ static public function formatString(s:String, pos:Position):Expr {
#if (neko || eval)
return Context.load("format_string", 2)(s, pos);
#end
@@ -0,0 +1,19 @@
+package unit.issues;
+#if !macro
+class Issue9928 extends unit.Test {
+ function test() {
+ var w = Std.random(10);
+ eq('hello $w', format('hello $w'));
+ }
+
+ macro static function format(s:String):haxe.macro.Expr;
+}
+#else
+ macro static function format(s:String):haxe.macro.Expr {
+ var p = haxe.macro.Context.currentPos();
+ var ed:{expr:haxe.macro.Expr.ExprDef} = haxe.macro.MacroStringTools.formatString(s, p);
+ return haxe.macro.MacroStringTools.formatString(s, p);
+#end