haxehaxeflixel

HaxeFlixel Unexpected & (amp) Character


I'm trying to get HaxeFlixel working. It works with lime test neko but doesn't work on lime test neko -debug. It says:

/usr/share/haxelib/flixel/4,6,0/flixel/effects/particles/FlxEmitter.hx:28: characters 34-35 : Unexpected &

And here's how the FlxEmitter.hx file looks around line 28:

typedef FlxEmitter = FlxTypedEmitter<FlxParticle>;

#if (haxe_ver >= "4.0.0")
class FlxTypedEmitter<T:FlxSprite & IFlxParticle> extends FlxTypedGroup<T> 
#else
class FlxTypedEmitter<T:(FlxSprite, IFlxParticle)> extends FlxTypedGroup<T>
#end
{
    /**
     * Set your own particle class type here. The custom class must extend `FlxParticle`. Default is `FlxParticle`.
     */
    public var particleClass:Class<T> = cast FlxParticle;

Here is my machine specifications:


Solution

  • As you can see, the code already checks the Haxe version in order to be compatible with both Haxe 3.4 and 4. This is necessary because the new type parameter constraint syntax is not backwards-compatible.

    Considering that, the only explanation is that you're using a build of Haxe 4 that hadn't introduced the new intersection type syntax using & yet. The first release with this feature was Haxe 4.0.0-preview.4. I suggest you try updating to the latest release, Haxe 4.0.0-rc.1.

    Haxe Compiler 4.0.0

    Note that Haxe didn't mention anything about preview releases in haxe --version until Haxe 4.0.0-preview.4. So while it may look like you have the final release of 4.0.0 installed, that actually hasn't happened yet and it's one of the early preview builds.