@@ -368,7 +368,7 @@ let reify in_macro =
| Meta.Dollar "i", _ ->
expr "EConst" [mk_enum "Constant" "CIdent" [e1] (pos e1)]
| Meta.Dollar "p", _ ->
- (ECall ((efield ((efield ((efield ((EConst (Ident "haxe"),p),"macro"),p),"MacroStringTools"),p),"toFieldExpr"),p),[e]),p)
+ (ECall ((efield ((efield ((efield ((EConst (Ident "haxe"),p),"macro"),p),"MacroStringTools"),p),"toFieldExpr"),p),[e1]),p)
| Meta.Pos, [pexpr] ->
let old = !cur_pos in
cur_pos := Some pexpr;
@@ -1664,6 +1664,9 @@ and type_meta ?(mode=MGet) ctx m e1 with_type p =
| (EReturn e, p) -> type_return ~implicit:true ctx e with_type p
| _ -> e()
end
+ | (Meta.Dollar s,_,p) ->
+ display_error ctx.com (Printf.sprintf "Reification $%s is not allowed outside of `macro` expression" s) p;
+ e()
in
ctx.meta <- old;
@@ -0,0 +1,15 @@
+class Main {
+ static function main() {
+ var foo = {"a": 1, "b": 1, "c": 1};
+ test();
+ trace($i{"wtf"});
+ }
+
+ static macro function test() {
+ var options:Array<haxe.macro.Expr> = [
+ for (s in ["a", "b", "c"])
+ macro @:pos(pos) $p{["foo", s]}
+ ];
+ return macro $b{options};
+}
@@ -0,0 +1,2 @@
+--main Main
+--interp
+Main.hx:5: characters 9-11 : Reification $i is not allowed outside of `macro` expression