Skip to content

[FEATURE] Add support for Structure Matching #324

@Starexify

Description

@Starexify

In haxe, we can use pattern matching on structures using switch statements (as documented in the Haxe Manual.

This example code from there:

var myStructure = {
  name: "haxe",
  rating: "awesome"
};
var value = switch (myStructure) {
  case {name: "haxe", rating: "poor"}:
    throw false;
  case {rating: "awesome", name: n}:
    n;
  case _:
    "no awesome language found";
}
trace(value);

would return haxe back

But in polymod this isn't supported and errors with these errors, or returns null if only the first case is used:

 ERROR  Error while executing function WorstCParser.onCreate()#0:
Tried to access "n", but it is not a valid field or method.
 ERROR  Error while executing function WorstCParser.onCreate()#0:
Tried to access "_", but it is not a valid field or method.

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