KB: How to resolve the X2 error. ;expected

Altium Designer Altium Designer
Users may encounter an error popup such as "X2 error ;expected" while running Design Rule Checks (DRC) or when copying and pasting PCB objects like tracks and vias. This issue is typically caused by incorrect syntax in custom queries defined within the Design Rules Editor or Constraint Manager. To resolve it, the built-in Query Helper tool can be used to validate and correct the query syntax, ensuring proper rule execution and object handling.

Solution Details

Problem Description

The error message "X2 error ;expected" appears during DRC execution or when performing copy/paste operations involving PCB objects such as tracks and vias. This indicates a failure in rule parsing due to malformed query syntax.

Why This Happens

The issue is caused by improperly formatted custom queries or invalid custom queries in the rule definition. These queries must follow specific syntax rules, and any deviation such as missing operators, incorrect field names, or unmatched parentheses can trigger errors. Altium flags these rules in red within the Design Rules Editor or Constraint Manager.

What to Do

To resolve syntax errors in custom queries, use one of the following methods:

  • Use the Query Helper in the Design Rules Editor
  • Use the Query Helper in the Constraint Manager

How to Do It

Using the Design Rules Editor:

  1. Navigate to Design ยป Rules.
  2. Open the Design Rules Editor.
  3. Locate the rule highlighted in red.
  4. Click on the rule to open its settings.
  5. Near the custom query field, click the Query Helper button.
  6. Click Check Syntax.
  7. Correct the syntax as needed.
  8. Click Apply, then OK.

Using the Constraint Manager:

  1. Open the Constraint Manager in the PCB document.
  2. Click on All Rules.
  3. Locate the advanced or custom rule.
  4. Click the ... button next to the custom query field.
  5. Open the Query Helper.
  6. Click Check Syntax.
  7. Correct the syntax as needed.
  8. Click Apply, then OK.

Additional Notes

  • Always validate custom queries before applying them to avoid rule check failures.
  • The Query Helper provides syntax suggestions and object references to assist in building valid queries.
  • Also check for objects or classes that are called but no longer exist in the design. If still referenced in the rule, this could also lead to the error. 

Related Articles

If you find an issue, select the text/image and pressCtrl + Enterto send us your feedback.