You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
False error: a switch case on a library enum (e.g. DayOfWeek) does not know its label (Found shows #MONDAY_value) #500
Follow-up to #494 / #497. A case label of an enum declared outside the project (a JDK or library enum such as java.time.DayOfWeek) is not linked to the same constant used elsewhere, so the case's condition adds no information. Correct code is rejected, and the message shows an internal name.
@StateSet({"closed", "open"})
classDoor {
@StateRefinement(to = "closed(this)") Door() {}
@StateRefinement(from = "closed(this)", to = "open(this)") voidopen() {}
@StateRefinement(from = "open(this)", to = "closed(this)") voidclose() {}
}
classLibEnum {
// Correct: the door is opened exactly on Mondays and closed exactly on Mondaysstaticvoidmonday(DayOfWeekday) {
Doord = newDoor();
if (day == DayOfWeek.MONDAY)
d.open();
switch (day) {
caseMONDAY:
d.close();
break;
default:
break;
}
}
}
State Refinement Error: found day == #MONDAY_value ? open(d) : closed(d) but expected open(d)
25 | d.close();
Hints:
- d can be in closed or open here, depending on the path taken, and no sequence of calls moves all of them to open. Make d reach this line in the same state on every path
Expected: no error, since inside case MONDAY the condition day == DayOfWeek.MONDAY holds. #MONDAY_value is an internal name users are not told about.
Enums declared in the project already work. Fix direction: translate library enum constants the same way in both the if condition and the case label (or give every enum constant a stable, distinct value), so case MONDAY adds day == DayOfWeek.MONDAY.
Not needed for the error-message study (no study exercise switches on a library enum).
Activity