haxe
haxe copied to clipboard
Trailing commas
Allow trailing commas in various positions:
class Main {
public static function main():Void {
foobar(
1,
2,
);
function blah(
a:Int,
b:Int,
):Void {}
var a = (
a:Int,
b:Int,
) -> 0;
var a:(
a:Int,
b:Int,
)->Int = null;
}
static function foobar(
a:Int,
b:Int,
):Void {}
}
enum Foo {
Bar(
a:Int,
b:Int,
);
}
function moduleFoobar(
a:Int,
b:Int,
):Void {}
- [x] (the actual parser change)
- [ ] tests?
- [ ] update the syntax used for haxe highlighting here and in the IDE?
Fixes https://github.com/HaxeFoundation/haxe/issues/1989
These display test failures don't seem to be random, we'll have to check what's going on there.
evil idea: "automatic comma insertion" just like ecmascript's "automatic semicolon insertion", insert a comma on line break when applicable.
btw some previously-in-my-mind other idea about next-line parentheses, or to be honest, semicolons:
an opening parenthesis is a function call (-like thing) iif it's directly preceded by an identifier (or keyword?) or
) ] }with no whitespace in between. // still no clear idea at declaration site. be consistent?
may also extend to "indexing bracket" vs "array/map literal beginning".
// but will never work for braces (unless we ban "naked block"? allow do{}; without while? only if(true){}? bbbtw do{}while() executes the body at least once, should it be allowed as value?)
Superseded by #11009.