Skip to content

Switch error only shows last line if caused by other program error #492

Description

@processing-bot

Created by: jwoLondon

Description

The following code displays the error ' on 'switch' has been suppressed, which is perhaps related to this problem without displaying the text of the actual error that caused the problem.

enum Option {
  CAT, DOG;
}

void setup() {
  Option option = Option.CAT;
  String noise;

  switch (option) {
  case CAT:
    noise = "miaow";
    break;
  case DOG:
    noise = "woof";
    break;
  }
  println(noise);
}

The full and correct error message is The local variable noise may not have been initialised. Note that a problem regarding missing 'default' on 'switch' has been suppressed, which is perhaps related to this problem. Without this context, the 'on switch has been suppressed' message will be confusing, especially to newer programmers.

The full message is temporarily displayed in the status line above the console when typing the line that first attempts to use 'noise' (println(noise); above), but not on running the program.

Expected Behavior

I would expect the full message to be displayed in the console on running. Or perhaps more helpfully just the first sentence The local variable noise may not have been initialised. since the switch error is a bit misleading.

Your Environment

  • Processing version: 4 beta 8
  • Operating System and OS version: MacOS 11.6.5 (Bug Sur)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions