Equivalent or rest parameter ? Not able to use macro expr. Getting errors

I am referencing this page:

to get an equivalent of rest parameter in AS3.0 .

Here is my code:

package myapp;
 import flash.display.*;
 import openfl.events.MouseEvent;
 import openfl.utils.Object ; 
 import openfl.display.Stage ;
 import openfl.events.Event ;
 import haxe.macro.Expr;
//about: testing rest arguments
//process: click on the stage to run the variable function 
class Main extends Sprite 
	var stage_St:Stage ;
 	public var my_Obj:Object;
public function new() 
	addEventListener(Event.ADDED_TO_STAGE , ats);

function ats(e):Void 
	stage_St = this.stage ; 
	stage_St.addEventListener(MouseEvent.CLICK, function(e)
		    myMacro("foo", a, b, c);


   macro   function myMacro(e1:Expr, extra:Array<Expr>) {
    for (e in extra) {
    return macro null;


Here are the errors :
for html5:

C:/HaxeToolkit/haxe/lib/lime/7,6,3/src/lime/graphics/opengl/GLBuffer.hx:16: characters 19-39 : You cannot access the js package while in a macro (for js.html.webgl.Buffer)
C:/HaxeToolkit/haxe/lib/lime/7,6,3/src/lime/_internal/backend/native/NativeCFFI.hx:4: characters 7-36 : referenced here
C:/HaxeToolkit/haxe/lib/lime/7,6,3/src/lime/graphics/Image.hx:7: characters 7-47 : referenced here
C:/HaxeToolkit/haxe/lib/lime/7,6,3/src/lime/ui/Window.hx:5: characters 7-26 : referenced here
C:/HaxeToolkit/haxe/lib/lime/7,6,3/src/lime/graphics/RenderContext.hx:4: characters 7-21 : referenced here
C:/HaxeToolkit/haxe/lib/lime/7,6,3/src/lime/app/Application.hx:3: characters 7-34 : referenced here
C:/HaxeToolkit/haxe/lib/openfl/8,9,5/src/openfl/display/Application.hx:5: characters 7-27 : referenced here
C:/HaxeToolkit/haxe/lib/openfl/8,9,5/src/openfl/_internal/Lib.hx:6: characters 7-33 : referenced here
C:/HaxeToolkit/haxe/lib/openfl/8,9,5/src/openfl/display/DisplayObject.hx:6: characters 7-27 : referenced here
C:/HaxeToolkit/haxe/lib/openfl/8,9,5/src/openfl/_internal/utils/TouchData.hx:3: characters 7-35 : referenced here
C:/HaxeToolkit/haxe/lib/openfl/8,9,5/src/openfl/display/Stage.hx:7: characters 7-39 : referenced here
myapp/Main.hx:6: characters 8-28 : referenced here
myapp/Main.hx:34: characters 6-29 : referenced here
Build halted with errors.
Error: Could not process argument Gagrani\AppData\Local\Android\Sdk
invalid character: \

For flash:

myapp/Main.hx:12: characters 19-25 : You cannot access the flash package while in a macro (for flash.display.Sprite)
Build halted with errors.

oh this is the old macro pollution issue :frowning:

importing class A imports class B which imports class C which imports js which is disallowed in a macro

Try wrapping your code in #if macro or #unless macro or put the macro into another class

1 Like