{"record":{"id":"3c900000bfee2602","repo":"evanw/esbuild","slug":"should-be-boolean","errorCode":null,"errorMessage":"Should be boolean","messagePattern":"Should be boolean","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/terser-tests.js","lineNumber":268,"sourceCode":"  return tests;\n\n  function croak(node) {\n    throw new Error(tmpl(\"Can't understand test file {file} [{line},{col}]\\n{code}\", {\n      file: file,\n      line: node.start.line,\n      col: node.start.col,\n      code: make_code(node, { beautify: false })\n    }));\n  }\n\n  function read_boolean(stat) {\n    if (stat.TYPE == \"SimpleStatement\") {\n      var body = stat.body;\n      if (body instanceof U.AST_Boolean) {\n        return body.value;\n      }\n    }\n    throw new Error(\"Should be boolean\");\n  }\n\n  function read_string(stat) {\n    if (stat.TYPE == \"SimpleStatement\") {\n      var body = stat.body;\n      switch (body.TYPE) {\n        case \"String\":\n          return body.value;\n        case \"Array\":\n          return body.elements.map(function (element) {\n            if (element.TYPE !== \"String\")\n              throw new Error(\"Should be array of strings\");\n            return element.value;\n          }).join(\"\\n\");\n      }\n    }\n    throw new Error(\"Should be string or array of strings\");\n  }","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/evanw/esbuild/blob/f6058f8364fe7ab91ca57a83e02577ed74c9cae4/scripts/terser-tests.js#L250-L286","documentation":"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.","triggerScenarios":"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.","commonSituations":"A contributor copies an `expect:` string-style field and reuses that syntax for `reminify:`, or quotes the boolean by mistake.","solutions":["Change the field value to a bare boolean literal: `reminify: true;` or `reminify: false;`.","Remove the `reminify:` field entirely if you want the default (the test object defaults reminify to true at line 292)."],"exampleFix":"// before\nreminify: \"true\";\n\n// after\nreminify: true;","handlingStrategy":"type-guard","validationCode":"// Verify a boolean field parses as AST_Boolean before delegating to read_boolean\nfunction looksLikeBooleanField(stat) {\n  return stat.TYPE === 'SimpleStatement' && stat.body instanceof U.AST_Boolean;\n}","typeGuard":"const isBooleanStatement = (stat) =>\n  stat.TYPE === 'SimpleStatement' && stat.body instanceof U.AST_Boolean;","tryCatchPattern":"try { read_boolean(stat); }\ncatch (e) {\n  if (/Should be boolean/.test(e.message)) console.error('Field must be a bare true/false literal');\n  throw e;\n}","preventionTips":["Always write boolean fields as bare true/false with no quotes or parentheses.","Remember the default for reminify is true; omit the field rather than guessing its type."],"tags":["test-harness","terser","validation","boolean","contributor"],"backgroundTag":null,"analyzedSha":"f6058f8364fe7ab91ca57a83e02577ed74c9cae4","analyzedAt":"2026-08-09T18:37:22.223Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}