# @:native doesn't work on the Lua target

**URL:** https://community.haxe.org/t/native-doesnt-work-on-the-lua-target/4640
**Category:** Haxe
**Tags:** macro, haxe-lua
**Created:** [July 13, 2025, 11:40am UTC](https://community.haxe.org/t/native-doesnt-work-on-the-lua-target/4640 "2025-07-13T11:40:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Davvex87](https://community.haxe.org/user_avatar/community.haxe.org/davvex87/32/2399_2.png) [@Davvex87](https://community.haxe.org/u/Davvex87)
#### Post date: [July 13, 2025, 11:40am UTC](https://community.haxe.org/t/native-doesnt-work-on-the-lua-target/4640/1 "2025-07-13T11:40:58Z")

</div>

I am writing Haxe bindings for Roblox’s Luau API for my [roblox-hx library](https://github.com/Davvex87/roblox-hx), which heavily depends on objects to run your Roblox games’ logic. While in Lua it’s generally acceptable to write fields in UpperCamelCase, this rule is not appropriate for Haxe programming so [@:native](https://haxe.org/manual/lf-externs-native.html) must be used to cover up this problem, but it does not appear to be working on versions prior to Haxe 5.0.0-preview1 and even Haxe 5 itself.

 ![image](https://community.haxe.org/uploads/default/original/2X/1/18406851167ee98250f572f76dd5236b1c9eef82.png)

No libraries or macros were used and no modifications to the standard library or to the compiler were made, only 2 defines were set:

```haxe
-D lua-vanilla
-D lua-ver=5.1

```

[Test project link](https://drive.google.com/file/d/1O8jlG6ECr3u9lQxgRdZRX4wmPIhnHK0i/view?usp=sharing)

Am I doing something wrong? Or is something really broken behind the scenes?

---

<div class="post-metadata">

### Author: ![tobil4sk](https://community.haxe.org/user_avatar/community.haxe.org/tobil4sk/32/1458_2.png) [@tobil4sk](https://community.haxe.org/u/tobil4sk)
#### Post date: [July 20, 2025, 9:32am UTC](https://community.haxe.org/t/native-doesnt-work-on-the-lua-target/4640/2 "2025-07-20T09:32:30Z")

</div>

I don’t think the current behaviour is correct. `@:native` isn’t respected if the function itself is marked as extern:

```haxe
extern class Native {
	@:native("Native")
	public static extern function native():Void;
}

function main() {
	Native.native();
}

```

This gives:

```lua
___Main_Main_Fields_.main = function() 
  Native.native();
end

```

vs.

```haxe
extern class Native {
	@:native("Native")
	public static function native():Void;
}

function main() {
	Native.native();
}

```

which gives:

```lua
___Main_Main_Fields_.main = function() 
  Native.Native();
end

```

This bug also happens on the js target, and other targets, so it would be worth opening an issue on github.

---

<div class="post-metadata">

### Author: ![Davvex87](https://community.haxe.org/user_avatar/community.haxe.org/davvex87/32/2399_2.png) [@Davvex87](https://community.haxe.org/u/Davvex87)
#### Post date: [July 20, 2025, 7:08pm UTC](https://community.haxe.org/t/native-doesnt-work-on-the-lua-target/4640/3 "2025-07-20T19:08:06Z")

</div>

That is really odd, but it works now. Tysm!
