Skip to content

[FEATURE] Add support for guards in switch statements #325

@Starexify

Description

@Starexify

In haxe, we can use guards in switch cases (as documented in the Haxe Manual.

This example code from there:

var myArray = [7, 6];
var s = switch (myArray) {
    case [a, b] if (b > a):
      b + ">" + a;
    case [a, b]:
      b + "<=" + a;
    case _: "found something else";
  }
trace(s); // 6<=7

would return 6<=7 back

But in polymod this isn't supported and errors with this:

 ERROR  Error while parsing script assets/scripts/WorstCParser.hxc#8: EUnexpected
Unexpected error: Unexpected token "if", is there invalid syntax on this line?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions