Skip to content

[Bug?]: Compiler Error for some unused variables #2160

@dertieran

Description

@dertieran

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Ran into an issue with unused variables in @solidjs/start@2.0.0-alpha.3.

  1. Unused errors in catch block
export function get_lucky() {
  "use server";

  try {
    if (Math.random() > 0.5) return true;
    throw new Error("Unlucky");
  } catch (error) {
    // BUG: Expected a semicolon (Note that you need plugins to import files that are not JavaScript)
    // noop(error);
    return false;
  }
}
  1. Unused destructured variable
export function load_items() {
  "use server";

  const items = [];
  for (const { _id, ...rest } of raw_items) {
    // BUG: Property left of ForOfStatement expected node to be of a type ["VariableDeclaration","LVal"] but instead got undefined
    // noop(_id);
    items.push(rest);
  }

  return items;
}

When the noop() calls are commented out the compilation fails.
If the variables are used it works as expected.
It also works with @solidjs/start@2.0.0-alpha.2.

Here is a StackBlitz that reproduces the error.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions