HaxeFoundation / HaxeFoundation/haxe

Wrong fields order for @:structInit object literal completion

Open
#10,958 0 comments 0 reactions 1 assignee Claimed by @kLabz View on GitHub
feature-structInit
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

```haxe
@:structInit
class Foo {
var b:Int;
var a:Int;
var z:Int;
var d:Int;
}

var foo:Foo = |
```

Choosing "Generate object literal" (creating an anonymous object using expected type returned by Haxe compiler) in completion there will lead to:
```haxe
var foo:Foo = {
z: z,
d: d,
b: b,
a: a
}
```

While we'd want (declaration order, which is what happens with typedefs for example):
```haxe
var foo:Foo = {
b: b,
a: a,
z: z,
d: d
}
```

Or at least (alphabetical order, which is what happens with field completion (`var foo:Foo = { | }` on `@:structInit`)):
```haxe
var foo:Foo = {
a: a,
b: b,
d: d,
z: z
}
```

Note that it also applies to:
```haxe
@:structInit
class Bar {
function new(b:Int,a:Int,z:Int,d:Int) {}
}
```
Where it seems like having declaration order instead of [currently reversed] alphabetical order would be better.

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.