HaxeFoundation / HaxeFoundation/haxe

[cpp] inlined assignment of Dynamic to String enum argument

Open
#6,447 1 comment 0 reactions 1 assignee Claimed by @hughsando View on GitHub
platform-cpp
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

```haxe
class Main {
public static function main() {
trace(f(new Main()));
}

public function new() {}

static inline function f(v:Dynamic) return Value(v);
}

enum E {
Value(s:String);
}
```

The `trace()` is just there so that the code isn't optimized away.

```
Error: Main.cpp
./src/Main.cpp(40): error C2664: 'E E_obj::Value(String)': cannot convert argument 1 from 'hx::ObjectPtr' to 'String'
./src/Main.cpp(40): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
```

The problematic line:

```cpp
HXDLIN( 3) ::E _hx_tmp1 = ::E_obj::Value( ::Main_obj::__alloc( HX_CTX ));
```

Seems to be a regression compared to Haxe 3.2.1.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.