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

Required block brackets are removed on case statements #61

Closed
Domi04151309 opened this issue Aug 8, 2023 · 1 comment
Closed

Required block brackets are removed on case statements #61

Domi04151309 opened this issue Aug 8, 2023 · 1 comment

Comments

@Domi04151309
Copy link

When rendering the following code using the formatter, it removes the brackets causing JavaScript execution to fail because of the redeclaration of a const variable.

Original Code
function loadData(data) {
  for (const [instruction, parameters] of data) switch (instruction) {
  case 'point': {
    const [vector, label] = parameters;
    CoordinateSystem.addPoint(vector, label);
    break;
  }
  case 'arrow': {
    const [start, end, label] = parameters;
    CoordinateSystem.addArrow(start, end, label);
    break;
  }
  case 'line': {
    const [start, direction, label] = parameters;
    CoordinateSystem.addLine(start, direction, label);
    break;
  }
  case 'plane': {
    const [normalVector, distance, label] = parameters;
    CoordinateSystem.addPlane(normalVector, distance, label);
    break;
  }
  default:
    console.warn('Unknown instruction type', instruction);
    break;
  }
}
Rendered Code
function loadData (data) {
	for (const [instruction, parameters] of data) {
		switch (instruction) {
			case 'point':
								const [vector, label] = parameters;
				CoordinateSystem.addPoint(vector, label);
				break;;
			case 'arrow':
								const [start, end, label] = parameters;
				CoordinateSystem.addArrow(start, end, label);
				break;;
			case 'line':
								const [start, direction, label] = parameters;
				CoordinateSystem.addLine(start, direction, label);
				break;;
			case 'plane':
								const [normalVector, distance, label] = parameters;
				CoordinateSystem.addPlane(normalVector, distance, label);
				break;;
			default:
				console.warn('Unknown instruction type', instruction);
				break;
		}
	}
}
@mck89 mck89 closed this as completed in 1df4dc2 Aug 12, 2023
@mck89
Copy link
Owner

mck89 commented Aug 12, 2023

Fixed, thank you for reporting.

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