Skip to content

pattern matching on polymorphism variant / extensible variant generates inefficient if chains #6908

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

Closed
hackwaly opened this issue Jul 24, 2024 · 2 comments

Comments

@hackwaly
Copy link

hackwaly commented Jul 24, 2024

Thus make them unusable indeed.

See https://rescript-lang.org/try?version=v11.1.2&code=C4TwDgpgBMULxQNoCgpQD5QMQBUCMqG2OATIZrgMznEAsNuArMgLrLIA2EswA9gMrAATgEsAdgHN4UABQAPAFwwAlPAB8UAN6EAzgHcRwAMYALKHK2EiuPOqgAifPasVSdxyWdprOSu99eaK60-rSBPoz+jIEAvsgxQA

type t = [
  | #T1
  | #T2
  | #T3
  | #T4
  | #T5
]

let toString = (x: t) => {
  switch x {
   | #T1 => "T1"
   | #T2 => "T2"
   | #T3 => "T3"
   | #T4 => "T4"
   | #T5 => "T5"
  }
}
// Generated by ReScript, PLEASE EDIT WITH CARE


function toString(x) {
  if (x === "T2") {
    return "T2";
  } else if (x === "T3") {
    return "T3";
  } else if (x === "T4") {
    return "T4";
  } else if (x === "T5") {
    return "T5";
  } else {
    return "T1";
  }
}

export {
  toString ,
}
/* No side effect */
@cristianoc
Copy link
Collaborator

Not planned.

@hackwaly
Copy link
Author

hackwaly commented Oct 23, 2024

related #7121

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants