{"record":{"id":"ddc32039162b11bf","repo":"evanw/esbuild","slug":"unsupported-input-syntax-ddc320","errorCode":null,"errorMessage":"Unsupported input syntax","messagePattern":"Unsupported input syntax","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/uglify-tests.js","lineNumber":470,"sourceCode":"    });\n    block.walk(tw);\n    return test;\n  }\n}\n\nfunction run_code(code, toplevel) {\n  const sandbox = require(path.join(uglifyDir, 'test', 'sandbox'));\n\n  var result = sandbox.run_code(code, toplevel);\n  return typeof result == \"string\" ? result.replace(/\\u001b\\[\\d+m/g, \"\") : result;\n}\n\nfunction tmpl() {\n  return U.string_template.apply(null, arguments);\n}\n\nfunction to_toplevel(input, mangle_options) {\n  if (!(input instanceof U.AST_BlockStatement)) throw new Error(\"Unsupported input syntax\");\n  var directive = true;\n  var offset = input.start.line;\n  var tokens = [];\n  var toplevel = new U.AST_Toplevel(input.transform(new U.TreeTransformer(function (node) {\n    if (U.push_uniq(tokens, node.start)) node.start.line -= offset;\n    if (!directive || node === input) return;\n    if (node instanceof U.AST_SimpleStatement && node.body instanceof U.AST_String) {\n      return new U.AST_Directive(node.body);\n    } else {\n      directive = false;\n    }\n  })));\n  toplevel.figure_out_scope(mangle_options);\n  return toplevel;\n}\n","sourceCodeStart":452,"sourceCodeEnd":486,"githubUrl":"https://github.com/evanw/esbuild/blob/f6058f8364fe7ab91ca57a83e02577ed74c9cae4/scripts/uglify-tests.js#L452-L486","documentation":"Thrown by to_toplevel() in scripts/uglify-tests.js:470. After parsing the test's `input:` value, the harness requires it to be an AST_BlockStatement (a brace-enclosed block). If the parsed input is any other node type (a single expression, a declaration, etc.), this error is raised before scope analysis.","triggerScenarios":"An uglify test's `input:` field is not wrapped in curly braces, so it parses to something other than an AST_BlockStatement. For example `input: var a = 1;` instead of `input: { var a = 1; }`.","commonSituations":"Contributor writes an input as a bare statement or omits the enclosing braces required by the compress-test DSL.","solutions":["Wrap the input body in `{ ... }` so it parses as a block statement.","Verify the input still reproduces the original bug after wrapping."],"exampleFix":"// before\ninput: var a = 1; console.log(a);\n\n// after\ninput: { var a = 1; console.log(a); }","handlingStrategy":"type-guard","validationCode":"function isBlockInput(parsedInput) {\n  return parsedInput instanceof U.AST_BlockStatement;\n}","typeGuard":"const isBlockStatement = (node) => node instanceof U.AST_BlockStatement;","tryCatchPattern":"try { to_toplevel(input, mangle); }\ncatch (e) {\n  if (/Unsupported input syntax/.test(e.message)) console.error('Wrap the input field body in { ... }');\n  throw e;\n}","preventionTips":["Always wrap an uglify test's `input:` value in curly braces so it parses as a block.","Validate the input is a block before calling to_toplevel."],"tags":["test-harness","uglify","validation","ast","contributor"],"backgroundTag":null,"analyzedSha":"f6058f8364fe7ab91ca57a83e02577ed74c9cae4","analyzedAt":"2026-08-09T18:37:22.223Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}