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"
Given the following code:
👆🏽 Currently this yells as a Type Error pointing at "c":
But I think this error is misleading, because really what the compiler is saying is that this is an incomplete logical case, e.g.
It would be helpful if the compiler said something closer to "Logically incomplete condition, there is a case which isn't yet accounted for"