Skip to content

ReScript v12 - pattern matching on optional fields breaks other cases #7400

Closed
@DZakh

Description

@DZakh

https://rescript-lang.org/try?version=v12.0.0-alpha.10&module=esmodule&code=C4TwDgpgBMCGDmUC8UBCB7dAbCsB2UAPlAHICuAtgEYQBOAUKJFAGbq0WzDJQCSewAMwAmeo3DQAzgGMAFhE48A3vShRp6PJOAB+AFxQqmLABpVrdp10G2HLmbVx4Bp2YC+YnN1oQWASzxoFBl5RSQAPigVNUkAdz9gOSgQhVgo82IlDS1gAwB9N2RIgCJijKjbKwN+IWFCiKhigNqytUynAwxsXDx6kqNu-FaiKDyixoATX1gyLGBhjw8gA

v12 (broken):

function refine(schema) {
  if (schema.const !== undefined) {
    return "";
  } else {
    return "int32";
  }
}

v11 (working):

function refine(schema) {
  if (schema.const !== undefined) {
    return "";
  } else if (schema.format !== undefined) {
    return "int32";
  } else if (schema.tag === "Boolean") {
    return "boolean";
  } else {
    return "default";
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions