Skip to content

Abstract with haxe.ds.Either breaks the compiler#12098

Description

@filt3rek

Hej,

Sorry again, I know you're tired of me 馃檭, and here, I even don't really know how to title that issue ...
A lot of time spent to isolate this issue : https://try.haxe.org/#f581b82f

abstract Outcome(Int) from Int to Int{		// Just comment this abstract and compiler "wake-up" lol
	@:from static inline function fromEither(ei:haxe.ds.Either<String, Err>): Outcome
		return switch ei {
			case Right(e): 1;
                        case _ : 2;
		}
}

abstract Err(Bool) from Bool to Bool {
	//inline function new() return true; // You can also omit the constructor...

	@:from inline static function fromInt(n:Int) {
		return new Err(here, you, can, write, what, you, want, lol);
	}
}

class Test {
	static function main() {
            var err : Err = 5;
            trace( err );
	}
}

It fails on all targets on try.haxe.
Just remove or comment the Outcome abstract and all works fine (I mean compiler throws the right errors and so on...)
The JS output is also "funny"...

Thanks for your help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions