Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing commas #10159

Closed

Conversation

Aurel300
Copy link
Member

@Aurel300 Aurel300 commented Mar 6, 2021

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 {}
  • (the actual parser change)
  • tests?
  • update the syntax used for haxe highlighting here and in the IDE?

@skial skial mentioned this pull request Mar 8, 2021
1 task
@RealyUniqueName RealyUniqueName added this to the Backlog milestone Mar 10, 2021
@RblSb
Copy link
Member

RblSb commented Dec 10, 2021

Fixes #1989

@Simn Simn force-pushed the feature/trailing-commas branch from d00d4ea to abefad4 Compare April 11, 2022 11:10
@Simn Simn self-assigned this Apr 11, 2022
@Simn
Copy link
Member

Simn commented Apr 18, 2022

These display test failures don't seem to be random, we'll have to check what's going on there.

@farteryhr
Copy link

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?)

@kLabz kLabz mentioned this pull request Mar 8, 2023
@Aurel300
Copy link
Member Author

Superseded by #11009.

@Aurel300 Aurel300 closed this Mar 12, 2023
@Aurel300 Aurel300 deleted the feature/trailing-commas branch March 12, 2023 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants