Skip to content

[plugin] fix load struct#948

Merged
yuxiaomao merged 1 commit into
HaxeFoundation:masterfrom
yuxiaomao:dev-plugin-struct
Jun 22, 2026
Merged

[plugin] fix load struct#948
yuxiaomao merged 1 commit into
HaxeFoundation:masterfrom
yuxiaomao:dev-plugin-struct

Conversation

@yuxiaomao

Copy link
Copy Markdown
Collaborator

Fix "Imported type 'SharedStruct' could not be resolved".

Repro: run with haxe build.hxml && haxe plugin.hxml && hl test.hl

// Main.hx
class Main {
	static function main() {
		hl.Api.loadPlugin("plugin.hl");
	}
}

@:struct
class SharedStruct {
	public var value:Int;
	public var name:String;
	public function new(value:Int, name:String) {
		this.value = value;
		this.name = name;
	}
	public function sum(v:Int):Int {
		return value + v;
	}
}
// Plugin.hx
class Plugin {
	static function main() {
		struct_resolve();
	}
	static function struct_resolve() {
		var s = new Main.SharedStruct(10, "hello");
		eq(s.value, 10);
		t(Std.isOfType(s, Main.SharedStruct));
	}
	static inline function eq<T>(actual:T, expected:T, ?infos:haxe.PosInfos) {
		if (actual != expected)
			haxe.Log.trace('FAIL: $actual, expected=$expected', infos);
		else
			haxe.Log.trace('OK: $actual', infos);
	}
	static inline function t(actual:Bool) {
		eq(actual, true);
	}
}
// build.hxml
--main Main
-D hl-check
--hl test.hl
// Plugin.hxml
-hl plugin.hl
-main Plugin
--macro exclude("SharedStruct")

@yuxiaomao yuxiaomao merged commit 8db7157 into HaxeFoundation:master Jun 22, 2026
30 checks passed
@yuxiaomao yuxiaomao deleted the dev-plugin-struct branch June 22, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant