evanw/esbuild · error · Error

Should be boolean

Error message

Should be boolean

What it means

Thrown by read_boolean() in scripts/terser-tests.js:268. The terser harness expects certain test fields (notably `reminify:`) to be a bare boolean literal. read_boolean() only accepts a SimpleStatement whose body is an AST_Boolean; anything else — a string, number, identifier, or parenthesized expression — triggers this error.

Source

Thrown at scripts/terser-tests.js:268

  return tests;

  function croak(node) {
    throw new Error(tmpl("Can't understand test file {file} [{line},{col}]\n{code}", {
      file: file,
      line: node.start.line,
      col: node.start.col,
      code: make_code(node, { beautify: false })
    }));
  }

  function read_boolean(stat) {
    if (stat.TYPE == "SimpleStatement") {
      var body = stat.body;
      if (body instanceof U.AST_Boolean) {
        return body.value;
      }
    }
    throw new Error("Should be boolean");
  }

  function read_string(stat) {
    if (stat.TYPE == "SimpleStatement") {
      var body = stat.body;
      switch (body.TYPE) {
        case "String":
          return body.value;
        case "Array":
          return body.elements.map(function (element) {
            if (element.TYPE !== "String")
              throw new Error("Should be array of strings");
            return element.value;
          }).join("\n");
      }
    }
    throw new Error("Should be string or array of strings");
  }

View on GitHub (pinned to f6058f8364)

Solutions

  1. Change the field value to a bare boolean literal: `reminify: true;` or `reminify: false;`.
  2. Remove the `reminify:` field entirely if you want the default (the test object defaults reminify to true at line 292).

Example fix

// before
reminify: "true";

// after
reminify: true;
Defensive patterns

Strategy: type-guard

Validate before calling

// Verify a boolean field parses as AST_Boolean before delegating to read_boolean
function looksLikeBooleanField(stat) {
  return stat.TYPE === 'SimpleStatement' && stat.body instanceof U.AST_Boolean;
}

Type guard

const isBooleanStatement = (stat) =>
  stat.TYPE === 'SimpleStatement' && stat.body instanceof U.AST_Boolean;

Try / catch

try { read_boolean(stat); }
catch (e) {
  if (/Should be boolean/.test(e.message)) console.error('Field must be a bare true/false literal');
  throw e;
}

Prevention

When it happens

Trigger: Writing `reminify: "true";`, `reminify: 1;`, `reminify: yes;`, or `reminify: (true);` in a terser test file. The field must be the literal keywords true or false as a direct simple statement.

Common situations: A contributor copies an `expect:` string-style field and reuses that syntax for `reminify:`, or quotes the boolean by mistake.

Related errors


AI-assisted analysis of evanw/esbuild@f6058f8364 (2026-08-09). Data as JSON: /api/errors/3c900000bfee2602. Report an issue: GitHub.