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

Incomplete logical case error #166

Open
brekk opened this issue Apr 22, 2024 · 0 comments
Open

Incomplete logical case error #166

brekk opened this issue Apr 22, 2024 · 0 comments

Comments

@brekk
Copy link
Contributor

brekk commented Apr 22, 2024

Given the following code:

conditions = (x) => {
  return if (x < 5) {
    "a"
  } else if (x >= 5 && x < 10) {
    if (x == 7 || x == 9) {
      "b1"
    } else {
      "b"
    }
  } else if (x < 15) {
    "c"
  }
}

👆🏽 Currently this yells as a Type Error pointing at "c":

[error]: Type error
     ╭──▶ /madness/examples/src/Temp.mad@22:5-22:8
     │
  22 │     "c"
     •     ┬──
     •     ╰╸ expected:
     •          String
     •
     •        but found:
     •          {}
     •
─────╯

But I think this error is misleading, because really what the compiler is saying is that this is an incomplete logical case, e.g.

conditions = (x) => {
  return if (x < 5) {
    "a"
  } else if (x >= 5 && x < 10) {
    if (x == 7 || x == 9) {
      "b1"
    } else {
      "b"
    }
  } else if (x < 15) {
    "c"
  } else {
    "d"
  }
}

It would be helpful if the compiler said something closer to "Logically incomplete condition, there is a case which isn't yet accounted for"

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

1 participant