HaxeFoundation / HaxeFoundation/haxe

Nightly Haxe/Hxcpp - Invalid constant when setting an abstract function param to a enum abstract value.

Open
#12,370 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

```hx
abstract class Foo {
abstract public function getData(type:Items = Sword):Void;
}

enum abstract Items(String) {
var Sword;
}
```
This code is considered fine on all targets besides hxcpp where we get the following error
```
[ERROR] src/Main.hx:8: characters 48-53
8 | abstract public function getData(type:Items = Sword):Void;
| ^^^^^
| Invalid constant : Sword
```
Error does not occur on haxe 4.3.7, on nightly haxe(5.0.0-preview.1+90a2a3c) js/neko/hl/eval all compile fine (https://try.haxe.org/#bf87b284)

Contributor guide

Open the contributing guide

Research direction

Start with the provided Haxe snippet and reproduce it on the hxcpp target, comparing Haxe 4.3.7 with nightly 5.0.0-preview.1+90a2a3c and the js, neko, hl, and eval results linked in the issue. Done means the enum abstract value is accepted as the default parameter on hxcpp without the Invalid constant error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.